Jump to content

CMD output from an other host


ptrex
 Share

Recommended Posts

Is in some way possible to grab the output of the cmd window of another host.

Without using some kind of temp files to store the data in ?

PSExec is an option but still it doesn't give the output to AutoIT, unless over a temp file.

I need a way to of direct access, as if I was running it locally.

Thanks

Link to comment
Share on other sites

Is in some way possible to grab the output of the cmd window of another host.

Without using some kind of temp files to store the data in ?

PSExec is an option but still it doesn't give the output to AutoIT, unless over a temp file.

I need a way to of direct access, as if I was running it locally.

Thanks

I think psexec in combination with StdOutRead() would work. There is information about this command and an added parameter to Run() in the beta help file. Also, here is an example of it being used.

Script

Hmm actually i'm not sure if that would work... because psexec would spawn the child process, but that information would not necessarily be returned to the psexec process. I'll try testing it.

Edit: psexec seems to contain the output from the command. I didn't have another pc handy to test remote execution, but it should work like the following code. One thing that I found is you have to terminate the psexec.exe process for some reason before the script continues. So, you'd have to find a delay that gives the command long enough to run without slowing your script down too much...

_psexecTest()

Func _psexecTest()
    Local $ipconfig = Run("psexec.exe -s ipconfig.exe", "", @SW_HIDE, 2)
    Local $data = ""
    Sleep(1000)
    ProcessClose("psexec.exe")
    While 1
        $data &= StdOutRead($ipconfig)
        If @error = -1 Then ExitLoop
    WEnd
    MsgBox(0, "Test", $data)
EndFunc
Edited by JMiller
Link to comment
Share on other sites

...Without using some kind of temp files to store the data in ?...

Well not with that condition :-) 'cuz even the std I/O functions create tmp file(s)... which (BTW) are left behind if the script terminates abnormally.

It might us help to know what you are attempting to run in that remote CMD window.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Thanks for all the feedback.

The application I am trying to run is some command line tool that belongs to our ERP system.

Which is not standard used everywhere.

So replicating this whould be hard on your side. the thing with this tool is that i can only be run at the server side, not from any client.

I need to grab the output from the CMD box to the client. I know I can to do with a temp file but I would prefer not to.

Any idea's are welcome.

Link to comment
Share on other sites

Well not with that condition :-) 'cuz even the std I/O functions create tmp file(s)... which (BTW) are left behind if the script terminates abnormally.

StdoutRead/StderrRead/StdinWrite? Uh, no they don't, unless you consider your virtual memory swap file a temp file...

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Link to comment
Share on other sites

  • 4 weeks later...

StdoutRead/StderrRead/StdinWrite? Uh, no they don't, unless you consider your virtual memory swap file a temp file...

As you can see, I don't get to this forum much.

If you are able to use the StdoutRead/StderrRead/StdinWrite functions without temp files being created, then I must have coded something wrong in this post:

http://www.autoitscript.com/forum/index.ph...st&p=173643

If you remove the last line of that code FileDelete("C:\Temp\scs???.tmp") you should have three temp files in the OS temp folder after running that code. They are just text files and they contain everything that the CMD screen would have displayed to the user including the info being sent from the script to the CMD window.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
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
 Share

  • Recently Browsing   0 members

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