Clay Posted April 7, 2009 Posted April 7, 2009 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.
Mobius Posted April 7, 2009 Posted April 7, 2009 (edited) 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. Ed:tweakage Edited April 7, 2009 by Mobius
Clay Posted April 7, 2009 Author Posted April 7, 2009 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. 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
Mobius Posted April 7, 2009 Posted April 7, 2009 (edited) 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 againED: Tangent what do you mean that actually worked?..... That method is as old as AutoIt3 and the Command shell combined. Any way glad it helped ya. No problem, glad to help . 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. RespectVlad Edited April 7, 2009 by Mobius
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