Jump to content

Send commands to hidden DOS window


Recommended Posts

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......

$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 by lhk69
Link to comment
Share on other sites

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().

:D

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

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

$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

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 by lhk69
Link to comment
Share on other sites

  • 4 weeks later...
  • 6 years later...
  • Moderators

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? :huh:

Please look at the dates of the thread in future. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...