madmatrix Posted July 31, 2008 Share Posted July 31, 2008 Hi All, I'm trying to get the output from the cmd window. Like when I telnet some device and prompt user name and password, I can recognize them and input appropriate user name and password. I know perl and tcl could do it. But not sure Autoit can do this also? Lou Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 31, 2008 Share Posted July 31, 2008 Hi All,I'm trying to get the output from the cmd window. Like when I telnet some device and prompt user name and password, I can recognize them and input appropriate user name and password. I know perl and tcl could do it. But not sure Autoit can do this also?LouBy default, AutoIt compiles as a Windows GUI app. As such, it has no direct interface to the Console environment. You notice this when you run ConsoleRead() and ConsoleWrite() and nothing happens in the "DOS Box",You could experiment with the compiler option (in the help file) to compile your script in CUI (Console User Interface) mode. ConsoleWrite() messages then go to the "DOS Box", though I'm not sure ConsoleRead() gets you the text from it.Haven't had time to experiment with it, but I'm interested in the results. 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...
cherdeg Posted August 7, 2008 Share Posted August 7, 2008 (edited) You could experiment with the compiler option (in the help file) to compile your script in CUI (Console User Interface) mode. ConsoleWrite() messages then go to the "DOS Box", though I'm not sure ConsoleRead() gets you the text from it.I can't find anything about this CUI mode in the helpfile, but would need it as well...how to set it within the code? We currently use "psinfo.exe -h" to get the list of installed MS-Hotfixes on out systems. Later versions of psinfo make problems on some of our systems. Therefor I'd like to replace it by a simple AutoIT command line tool that queries the cimv2 WMI provider...my code up to now is this: ;#################################################################### ;# ;# Christoph Herdeg, August 2008 ;# http://www.cs-it-solutions.de ;# ;#################################################################### ; Declare the needed variables ; ===================================================================== Global $s_ComputerName = @ComputerName Global $objWMIservice Global $colItems Global $objItem Global $a_Text ; Set the WMI provider to \root\cimv2 of the local host ; ===================================================================== $objWMIservice = ObjGet("winmgmts:\\" & $s_ComputerName & "\root\cimv2") ; Do query items of class win32_quickfixengineering that start with the characters K or Q ; ===================================================================== If (IsObj($objWMIservice)) And (Not @error) Then $colItems = $objWMIservice.ExecQuery("SELECT * FROM win32_quickfixengineering WHERE HotFixId LIKE ""[KQ]%""") For $objItem In $colItems $a_Text &= "Patch ID: " & $objItem.HotFixId & @CRLF Next EndIf ; (hopefully som time soon) Writes ot the installed patches to the command line ; ===================================================================== ; MsgBox("", "Installed Patches", "Installed Patches: " & @CRLF & $a_Text) ConsoleWrite("Installed Patches: " & @CRLF & "===================" & @CRLF & $a_Text & @CRLF) Thank you very much for a little bit of info... Regards, Chris Edited August 7, 2008 by cherdeg Link to comment Share on other sites More sharing options...
cherdeg Posted August 7, 2008 Share Posted August 7, 2008 Thanks all...searching might help sometimes...just add the following line to your code to get your ConsoleWrite() to DOS windows: #AutoIt3Wrapper_Change2CUI=y Regards, Chris Link to comment Share on other sites More sharing options...
madmatrix Posted August 13, 2008 Author Share Posted August 13, 2008 Thanks all...searching might help sometimes...just add the following line to your code to get your ConsoleWrite() to DOS windows: #AutoIt3Wrapper_Change2CUI=y Regards, Chris Thanks for this tip. I tried to compile my script and run my .exe file. But it seems "telnet" command didn't execute. No any response from cosole window. ConsoleRead didn't caputre anything. I replaced ConsoleRead() by StdinRead, still nothing captured: #AutoIt3Wrapper_Change2CUI=y #include <Constants.au3> Local $foo = Run(@ComSpec & " /c " & "telnet.exe", @SystemDir, @SW_MAXIMIZE, $STDIN_CHILD + $STDOUT_CHILD) ConsoleWrite("open wodrivswt4" & @CR) Local $data While True $data &= StdoutRead($foo) If @error Then ExitLoop Sleep(25) WEnd MsgBox(0, "Debug", $data) 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