Jump to content
Sign in to follow this  
Clay

Commandline Output

Recommended Posts

Clay

Hey guys,

It's been a while since I have been on here but I ran into a snag and i'm wondering if anyone can provide some insight incite:

So I have a script... and in my script I am executing an external program (of mine) which produces some output in the commandline window. I am attempting to direct my output to a text file by using the command line option "> output.txt" in my Autoit script when using Run or ShellExecute.

ShellExecuteWait($MyProg, $USERNAME & " " & $i_Prod  & " " & $i_ProdVer & " " & $request_id & " > result.txt", _PathFull(@ScriptDir & "..\Prog\"), "", @SW_MAXIMIZE )

or 

RunWait($MyProg & " " & $USERNAME & " " & $i_Prod  & " " & $i_ProdVer & " " & $request_id & " > result.txt" , _PathFull(@ScriptDir & "..\Prog\"), @SW_MAXIMIZE)

I get no output file when I ran this though my Autoit script but if I just ran this manually thought commandline I do get the output file.

Any reason why? Any Ideas what I should try. I don't think I have many options but I thought I would at least try for opinions.

Share this post


Link to post
Share on other sites
Mobius

Hi Clay,

The '>' redirection switch does not work outside the command shell because it is an integral part of it.

try

RunWait(@COMSPEC &" /C " & $MyProg & " " & $USERNAME & " " & $i_Prod  & " " & $i_ProdVer & " " & $request_id & " > result.txt" , _PathFull(@ScriptDir & "..\Prog\"), @SW_MAXIMIZE)

Using this method you are invoking the command shell via its commandline parameters so special switches like '>' are supported.

of course you could use the @SW_HIDE macro if you just wanted to dump to file, since you will not get much output if you

redirect in this manner anyway.

also there are literaly Hundreds of references to this method plus user defined functions in this forum have a search about. :D

Ed:tweakage

Edited by Mobius

Share this post


Link to post
Share on other sites
Clay

Hi Clay,

The '>' redirection switch does not work outside the command shell because it is an integral part of it.

try

RunWait(@COMSPEC &" /C " & $MyProg & " " & $USERNAME & " " & $i_Prod  & " " & $i_ProdVer & " " & $request_id & " > result.txt" , _PathFull(@ScriptDir & "..\Prog\"), @SW_MAXIMIZE)

Using this method you are invoking the command shell via its commandline parameters so special switches like '>' are supported.

of course you could use the @SW_HIDE macro if you just wanted to dump to file, since you will not get much output if you

redirect in this manner anyway.

also there are literaly Hundreds of references to this method plus user defined functions in this forum have a search about. :D

Ed:tweakage

That actually worked...... Thank you..... I guess it's not so bad asking for help sometimes.

Also, I did search before posting, but I search Autoit WSH output and that provided me with no usable results .... I guess my keywords were off.

Thanks again

Share this post


Link to post
Share on other sites
Mobius

That actually worked...... Thank you..... I guess it's not so bad asking for help sometimes.

Also, I did search before posting, but I search Autoit WSH output and that provided me with no usable results .... I guess my keywords were off.

Thanks again

ED: Tangent

:o what do you mean that actually worked?..... That method is as old as AutoIt3 and the Command shell combined. :D

Any way glad it helped ya.

No problem, glad to help . :P

Also suggest you check out the Run() function plus its $STDIN_CHILD - $STDOUT_CHILD and $STDERR_CHILD flags,

if you wish to feed your programs output directly to AutoIt, But I prefer the cmd shell switches myself too mostly. :D

Respect

Vlad

Edited by Mobius

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.