tannerli Posted May 22, 2007 Share Posted May 22, 2007 Hi Guys! I hope someone can help me this time so easily as last time i was in trouble..... I want to run a ftp-session in a cmd with the ftp-command... but not only on command, i have to read the answer from the ftp-server from the stdout-stream but if i call it like that $PID=Run(@ComSpec & " /c ftp -n" & $HOST, @SystemDir, @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD + $STDIN_CHILD) oÝ÷ Ú+^Åç.µë-ç(f§u»Éh±ë-êk¡Ç¬±«¨«bq©eÊ,Ûh±éÝÞr¦jwl¶ÚâyÖ¥²hq©e¶×±{j|¢iÖ®¶s`¢b33c·7G&VÓÕ'Vâ6öÕ7V2Â77FVÔF"Â5uõ4õrÂb33cµ5DDU%%ô4ÄB²b33cµ5DDõUEô4ÄB²b33cµ5DDåô4ÄB same result, i can read from stdout but i closes the process automatically i'd be grateful for any suggestions (i can't solve my problem with ftp.au3 which i already found) Greetings tannerli Link to comment Share on other sites More sharing options...
tannerli Posted May 22, 2007 Author Share Posted May 22, 2007 (edited) I've found the solution of the problem, it was a missing space after the "-n" bu now i got already a new one it works if i run it like that $PID=Run(@ComSpec & " /c ftp -n " & $HOST, "H:\", @SW_SHOW) oÝ÷ Ù§íz»aÉbè ¢Ö§¢§Â)Ý£0ØmêÞ²'±ê+®÷«jwmçí¦i®©¶0z÷«ø¯+h©ÚæjÖ¬¶·«¢+Ø(ÀÌØíA%õIÕ¸¡ ½µMÁµÀìÅÕ½Ðì½ÑÀµ¸ÅÕ½ÐìµÀìÀÌØí!=MP°ÅÕ½Ðí èÀäÈìÅÕ½Ðì°M]}M!=°ÀÌØíMQ=UQ} !%1¤( the window appears only for a second (without any text) and then the cmd.exe process ends Edited May 22, 2007 by tannerli Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 22, 2007 Share Posted May 22, 2007 (edited) I'm not sure exactly what your issue is, but while trying to duplicate it I came across my own weirdness. This script just runs FTP, does 'help', then does 'quit': Dim $OutStream, $ErrStream $PID = Run("ftp -n", @TempDir, @SW_MINIMIZE, 7) ; 7 = connect to all streams If Not @error Then StdinWrite($PID, "help" & @CRLF) $Timer = TimerInit() Do If StdoutRead($PID, 0, 1) Then $OutStream = StdoutRead($PID) If StderrRead($PID, 0, 1) Then $ErrStream = StderrRead($PID) Until TimerDiff($Timer) > 2000 ; read for 2 sec ConsoleWrite("STDOUT = " & $OutStream & @LF & "STDERR = " & $ErrStream & @LF) StdinWrite($PID, "quit" & @CRLF) EndIf The output shows: STDOUT = Commands may be abbreviated. Commands are: STDERR = So I'm seeing the output, but not all of it... weird... Edited May 22, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
GMK Posted May 22, 2007 Share Posted May 22, 2007 I don't know what you want to do with the output returned by the server, but if a log suits your needs, this might help: $PID = Run('"' & @ComSpec & '" /c ftp -n >ftplog.txt', @TempDir, @SW_HIDE, 7) If Not @error Then ;Insert FTP commands here: StdinWrite($PID, "help" & @CRLF) StdinWrite($PID, "quit" & @CRLF) EndIf ProcessWaitClose("ftp.exe") Run('notepad.exe "' & @TempDir & '\ftplog.txt"') Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 22, 2007 Share Posted May 22, 2007 I don't know what you want to do with the output returned by the server, but if a log suits your needs, this might help: $PID = Run('"' & @ComSpec & '" /c ftp -n >ftplog.txt', @TempDir, @SW_HIDE, 7) If Not @error Then ;Insert FTP commands here: StdinWrite($PID, "help" & @CRLF) StdinWrite($PID, "quit" & @CRLF) EndIf ProcessWaitClose("ftp.exe") Run('notepad.exe "' & @TempDir & '\ftplog.txt"') That works, but only adds to the confusion. Your code uses standard_i/o_flag of 7 (same as my code earlier) which means all of them: 1 ($STDIN_CHILD) = Provide a handle to the child's STDIN stream 2 ($STDOUT_CHILD) = Provide a handle to the child's STDOUT stream 4 ($STDERR_CHILD) = Provide a handle to the child's STDERR stream If the STDOUT and STDERR have been hooked by AutoIt, why does the data show up in the log file? And when the log file option was not used (in mine), why did the first line of 'help' show up and not the list of commands? The windows console is a strange, conflicted place to work... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
tannerli Posted May 23, 2007 Author Share Posted May 23, 2007 The windows console is a strange, conflicted place to work...How very true......If the STDOUT and STDERR have been hooked by AutoIt, why does the data show up in the log file? And when the log file option was not used (in mine), why did the first line of 'help' show up and not the list of commands?I didn't solve my problem but i think i know why this happens...You start a cmd.exe process and control its data streams, cmd.exe itself starts ftp.exe and cmd controls the streams of ftp so you dont have the control about the ftp(And i think cmd passes its input to ftp so you can indirectly control ftp) Link to comment Share on other sites More sharing options...
Administrators Jon Posted May 23, 2007 Administrators Share Posted May 23, 2007 test Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 23, 2007 Share Posted May 23, 2007 How very true......I didn't solve my problem but i think i know why this happens...You start a cmd.exe process and control its data streams, cmd.exe itself starts ftp.exe and cmd controls the streams of ftp so you dont have the control about the ftp(And i think cmd passes its input to ftp so you can indirectly control ftp)Hmm... Your script used @ComSpec, and therefor opened a shell with cmd.exe, passing parameters after " /c " for the command. Mine ran ftp.exe directly without directly invoking the shell.But I think in the background windows saw it as a console app and did the exact same thing anyway.On the up side, I think there are others working on a scriptable, interactive ftp client in AutoIt. Search the Example Scripts forum especially for them. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
GaryFrost Posted May 23, 2007 Share Posted May 23, 2007 [q Little problem today? SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
GaryFrost Posted May 23, 2007 Share Posted May 23, 2007 I'll take that as a yes. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
GaryFrost Posted May 23, 2007 Share Posted May 23, 2007 Would suggest going to the test thread till you get it fixed. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Gif Posted May 23, 2007 Share Posted May 23, 2007 strange thread Link to comment Share on other sites More sharing options...
herewasplato Posted May 23, 2007 Share Posted May 23, 2007 Would suggest going to the test thread till you get it fixed.Each attempted post timed out.Once I saw the partial posts, I deleted them and the forum showed me that the delete function worked. My partial posts were gone.I posted to and deleted from the Chat/test thread.I PM'd Jon - hence his test post to this thread.I PM'd PsaltyDS - and PsaltyDS was able to post.I posted to another thread without any problems - it was just this thread.I cleared temp cache, exited IE6 - but still could not post to this thread...Now that I can - all that I wanted to say was try Run("ftp") with all of the STDIO stuff. Don't go thru CMD.Of course, I could be wrong and maybe the AutoIt gods were just attempting to keep me from looking like a fool by not letting me post that suggestions - but I'll show them. I can look like a fool even without posting to this thread!-MSSSSSP- [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 23, 2007 Share Posted May 23, 2007 I cleared temp cache, exited IE6 - but still could not post to this thread...MS Internet Exploder... "Well, THERE'S your problem..." - Jamie Hynaman (Myth Busters)Didja' try it in Firefox? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
herewasplato Posted May 23, 2007 Share Posted May 23, 2007 (edited) ...Firefox?...:-)I don't have that installed atm on my office system and I figured it had to be a forum issue to have shown the deletions as completed. Perhaps I was only seeing/deleting some of the partial posts.Have we (like I helped) solved the OP's issue? Edited July 31, 2007 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
tannerli Posted July 31, 2007 Author Share Posted July 31, 2007 Dim $OutStream, $ErrStream $PID = Run("ftp -n", @TempDir, @SW_MINIMIZE, 7) ; 7 = connect to all streams If Not @error Then StdinWrite($PID, "help" & @CRLF) $Timer = TimerInit() Do If StdoutRead($PID, 0, 1) Then $OutStream = StdoutRead($PID) If StderrRead($PID, 0, 1) Then $ErrStream = StderrRead($PID) Until TimerDiff($Timer) > 2000 ; read for 2 sec ConsoleWrite("STDOUT = " & $OutStream & @LF & "STDERR = " & $ErrStream & @LF) StdinWrite($PID, "quit" & @CRLF) EndIfoÝ÷ Ù8qj¢ú+Ê«éi*k¢ Ú+'£ îx§)æÊßǨޡûazX¯zÇ«½êìz÷«Êק)îµëºÇ¶¶ë¢cìj[r &§v)©®Þv+Z+mæÞq«¬z+jë³]4r®±¨ë-ºÇ¬ç©{-y§h~ئz¸§ßíg«v'ßjëh×6Dim $OutStream, $ErrStream $PID = Run("ftp -n", @TempDir, @SW_MINIMIZE, 7) ; 7 = connect to all streams If Not @error Then StdinWrite($PID, "help" & @CRLF) Sleep(2000) If StdoutRead($PID, 0, 1) Then $OutStream = StdoutRead($PID) If StderrRead($PID, 0, 1) Then $ErrStream = StderrRead($PID) ConsoleWrite("STDOUT = " & $OutStream & @LF & "STDERR = " & $ErrStream & @LF) StdinWrite($PID, "quit" & @CRLF) EndIf Greetings, tannerli Link to comment Share on other sites More sharing options...
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