Jump to content
Sign in to follow this  
AvN

Send the results of each commands to file

Recommended Posts

AvN

Hi there,

I am having a real problem here since yesterday.

I wrote a program to open cmd.exe. When this is opened I will use telnet to connect to a device.

When the connection is made, I am sending a series of command. Each command should output couple of lines. And I am suppose to save those line in a separate file. My problem is how to read those line from cmd.exe window and send them to the file that I create.

Here is what I tried:

$logFile =("C:\Documents and Settings\My Documents\log\logfile.txt")

Run ("C:\WINNT\system32\CMD") ;opening cmd

WinWaitActive ("C:\WINNT\system32\CMD.exe")

sleep(1000)

Send ("telnet 100.03.100.21{enter}") ; connecting via telnet

Sleep (2000)

WinWait ("C:\WINNT\system32\CMD.exe - telnet 100.03.100.21"); wait until connection is made

_FileWriteLog($logFile, "Testing Start Here") ; creating a log file

sleep (500)

Send ("< shared/vx_dvt.sh{enter}"); send first command to communicate with the device

Sleep (2000)

Send ("DVT_PRO_Menu{enter}") ; sending another command to get the menu from the device

sleep (4000)

Send ("32{enter}") ; another command

Sleep (2000)

send ("4000{enter}") ; another command

Sleep(2000)

Send ("42{enter}") ; another command

Sleep (2000)

Send ("30{enter}") ; another command

Sleep (2000)

Now, my real problem is how to take what each command is giving me and send it to the file created, logFile? for example by sending 32 or 42, this gives me couple of lines. Example send ("32{enter}") will say: Ther required temperature at this level is 50 degree. Now how to save those words in my logFile?

Thank you for your help.

Share this post


Link to post
Share on other sites
darkjohn20

Getting the result from a command prompt is relevant to my interests as well. Any ideas?

Share this post


Link to post
Share on other sites
bo8ster

StdoutRead is what you are looking for. The help file has a great example.

I also made an example here http://www.autoitscript.com/forum/index.php?showtopic=103447&st=0&p=733083&#entry733083


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×