Glyph Posted May 22, 2007 Posted May 22, 2007 Dim $iMainSocket = -1, $iSocket = -1 Dim $buffer = "" Dim $bytes = -1 Dim $iRet = -1 TCPStartup() $iMainSocket = TCPListen(@IPAddress1,5656) While 1 If $iSocket = -1 Then $iRet = TCPAccept($iMainSocket) If Not @error Then $iSocket = $iRet Else $buffer &= TCPRecv($iSocket,4096) If $bytes = -1 And StringInStr($buffer,",") Then $bytes = StringLeft($buffer,StringInStr($buffer,",")-1) $buffer = StringTrimLeft($buffer,StringInStr($buffer,",")) Else If StringLen($buffer) = $bytes Then [i] $FileReceived = FileSaveDialog("File save",@DesktopDir,"All (*.*)") [/i] ExitLoop EndIf EndIf EndIf WEnd FileDelete($FileReceived) FileWrite($FileReceived,$buffer) MsgBox(4096,"","Transfer Complete "&$FileReceived&" Saved from socket "&$imainsocket) TCPShutdown() run("Test.exe") ExitHow would i have it save " $FileReceived = FileSaveDialog("File save",@DesktopDir,"All (*.*)") "without the dialog, i can't be at my server 24.7 to accept the popup... so i need a way to accept the text file without a popup. i don't see anything in the help file either! tolle indicium
enaiman Posted May 22, 2007 Posted May 22, 2007 Not tested but it should work - I've used FileCopy instead. Dim $iMainSocket = -1, $iSocket = -1 Dim $buffer = "" Dim $bytes = -1 Dim $iRet = -1 Dim $FileReceived = @DesktopDir&"\temp_receive.txt" TCPStartup() $iMainSocket = TCPListen(@IPAddress1,5656) While 1 If $iSocket = -1 Then $iRet = TCPAccept($iMainSocket) If Not @error Then $iSocket = $iRet Else $buffer &= TCPRecv($iSocket,4096) If $bytes = -1 And StringInStr($buffer,",") Then $bytes = StringLeft($buffer,StringInStr($buffer,",")-1) $buffer = StringTrimLeft($buffer,StringInStr($buffer,",")) Else If StringLen($buffer) = $bytes Then FileClose(FileOpen($FileReceived, 2)) ;clear the file content FileWrite($FileReceived,$buffer) FileCopy($FileReceived, @DesktopDir&"\file_received_"&@MDAY&"-"&@MON&"-"&@YEAR&" "&@HOUR&"h"&@MIN&".txt", 9) ;change here whatever suits you ExitLoop EndIf EndIf EndIf WEnd ;FileDelete($FileReceived) ;you don't need these anymore ;FileWrite($FileReceived,$buffer) MsgBox(4096,"","Transfer Complete "&$FileReceived&" Saved from socket "&$imainsocket) TCPShutdown() run("Test.exe") SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
Glyph Posted May 23, 2007 Author Posted May 23, 2007 (edited) Awesome!, I didn't realize a filecopy would work... i actually thought about that too, but didn't try it! Edited May 23, 2007 by backstabbed tolle indicium
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now