lhk69 Posted July 17, 2006 Share Posted July 17, 2006 (edited) Hi. Basically, I am trying to telnet to a server, then send commands. This all works fine, except when hidden. This script asked user for information, then telnets to server (creates log file to read - so script knows when the search either found results or not), logs in, then does lookup and returns results in msgbox. All telnet/DOS functions need to be hidden. See code snippet..... I have looked at controlsend, but the dos window has no controlID. I am new and this is probably sloppy coding and I am probably missing the obvious...... expandcollapse popup$VOLUME= InputBox("Volume","Please type the volume to search") $i = 10 Dim $line Dim $x Dim $file Run("cmd.exe") Sleep(1000) Send('telnet -f C:\test.txt SERVER_NAME 23{ENTER}') Sleep(1000) Send("acssa{ENTER}") Sleep(1000) Send("PASSWORD{ENTER}") Sleep(3000) Send("vt100{ENTER}") Sleep(2000) Send("q vol ") Send( $VOLUME ) Send("{ENTER}") $file = FileOpen("c:\test.txt", 0) $x = 0 While 1 $line = FileReadLine($file,26) ; msgbox(1,"Line that was read is.....",$line) $x = 1 Sleep(100) $IT=StringInStr($line,"Home",0,1) ; MsgBox(1, "IT is", $IT) ; MsgBox(1, "X ", $x ,1) ; MsgBox(1, "Line after stringinstr", $x & " " & $line,1) If $x = 1 And StringInStr($line, "Home", 0, 1) > 0 Then If Not WinActive("Telnet SERVER_NAME", "") Then WinActivate("Telnet SERVER_NAME", "") WinWaitActive("Telnet SERVER_NAME", "") Send("log{ENTER}") WinClose("Telnet SERVER_NAME", "") ; Send("exit{ENTER}") msgbox(1,"Results", $VOLUME & " is in the silo.") ExitLoop EndIf If $x = 1 And StringInStr($line, "ejected", 0, 1) > 0 Then If Not WinActive("Telnet SERVER_NAME", "") Then WinActivate("Telnet SERVER_NAME", "") WinWaitActive("Telnet SERVER_NAME", "") Send("log{ENTER}") WinClose("Telnet SERVER_NAME", "") ; Send("exit{ENTER}") msgbox(1,"Results", $VOLUME & " is NOT in the silo.") ExitLoop EndIf If $x = 1 And StringInStr($line, "found", 0, 1) > 0 Then If Not WinActive("Telnet SERVER_NAME", "") Then WinActivate("Telnet SERVER_NAME", "") WinWaitActive("Telnet SERVER_NAME", "") Send("log{ENTER}") WinClose("Telnet SERVER_NAME", "") ; Send("exit{ENTER}") msgbox(1,"Results", $VOLUME & " is NOT in the silo.") ExitLoop EndIf WEnd FileClose($file) FileDelete ( $file ) Exit Thanks in advance for all suggestion. Edited July 19, 2006 by lhk69 Link to comment Share on other sites More sharing options...
jvanegmond Posted July 17, 2006 Share Posted July 17, 2006 Don't have much time: StdIn and StdOut Not easy, good luck github.com/jvanegmond Link to comment Share on other sites More sharing options...
lhk69 Posted July 18, 2006 Author Share Posted July 18, 2006 Don't have much time: StdIn and StdOutNot easy, good luck thanks, I'll try tomorrow.btw, like your avatar pic. Link to comment Share on other sites More sharing options...
jvanegmond Posted July 18, 2006 Share Posted July 18, 2006 (edited) Thanks, i own the instrument. It's a picture of the web though. Edited July 18, 2006 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
lhk69 Posted July 18, 2006 Author Share Posted July 18, 2006 I am having a difficult time getting stdin and sdtout to work. Keepsa claiming unknown function. I have included constants. Any ideas, or other suggestions? Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 19, 2006 Share Posted July 19, 2006 I am having a difficult time getting stdin and sdtout to work. Keepsa claiming unknown function. I have included constants. Any ideas, or other suggestions?Have to be running Beta to use StdInWrite() and StdOutRead(). 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...
lhk69 Posted July 19, 2006 Author Share Posted July 19, 2006 ok, I installed the bata in another dir, but wasnt pointing to it properly. I am now. here is a code snippet... $MyTelnet = Run(@COMSPEC & " /c " & "telnet -f C:\telnet_log.txt server1 23","",$STDIN_CHILD + $STDOUT_CHILD) MsgBox(4096, "", $MyTelnet ) StdinWrite( $MyTelnet, "username" & @CRLF & "password" & @CRLF) StdinWrite( $MyTelnet ) Exit opens telnet window, and connects. Never seems to pass the text specified in StdinWrite to the process. What am I missing? thank you very much. Link to comment Share on other sites More sharing options...
Skruge Posted July 19, 2006 Share Posted July 19, 2006 $MyTelnet = Run(@COMSPEC & " /c " & "telnet -f C:\telnet_log.txt server1 23","",$STDIN_CHILD + $STDOUT_CHILD) What am I missing?Welcome to the forums! Your Run function is missing the "show" flag. Try this:$MyTelnet = Run(@COMSPEC & " /c " & "telnet -f C:\telnet_log.txt server1 23", "", @SW_SHOW, $STDIN_CHILD + $STDOUT_CHILD)Once you've got your process debugged you can switch it to @SW_HIDE. [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
AzKay Posted July 19, 2006 Share Posted July 19, 2006 Cant you just use control send? $Com = Run(@ComSpec) ControlSend(@ComSpec, "", "", "stufftosend") Worked for me # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
lhk69 Posted July 20, 2006 Author Share Posted July 20, 2006 (edited) ok, here is what I have now. $MyTelnet = Run( "telnet -f C:\telnet_log.txt server1 23", "", @SW_SHOW, $STDIN_CHILD + $STDOUT_CHILD + $STDERR_CHILD) MsgBox(4096, "ProcessID is....", $MyTelnet ) StdinWrite( $MyTelnet, "acsss" & @CRLF ) sleep (1000) StdinWrite( $MyTelnet, "" & @CRLF ) sleep (2000) StdinWrite( $MyTelnet, "vt100" & @CRLF ) sleep (2000) StdinWrite( $MyTelnet, "q vol " & @CRLF & $VOLUME) StdinWrite( $MyTelnet ) what happens now, is I see the telnet window flash for a milisecond, then nothing is sent to it. Then the script continues, but of course with no results. Any ideas? Am I missing another parameter. I dont think I can use controlsend, because there is no control ID to send to a dos window. Edited August 16, 2006 by lhk69 Link to comment Share on other sites More sharing options...
lhk69 Posted August 16, 2006 Author Share Posted August 16, 2006 HELP. Still cant figure it out. ANY ideas??? Link to comment Share on other sites More sharing options...
lordsprinkles Posted June 6, 2013 Share Posted June 6, 2013 I was looking for a way to send a command to a dos window as well. AzKay's post worked for me, using ControlSend() with @ComSpec. You don't need a Control_ID, you can leave it blank like he wrote it. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 6, 2013 Moderators Share Posted June 6, 2013 lordsprinkles, Do you really think he is going to read your post, or is even interested in it, after 7 years absence from the forum? Please look at the dates of the thread in future. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts