AutoHotkey Community

It is currently May 27th, 2012, 1:04 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: RunWait Pipe
PostPosted: December 15th, 2011, 10:49 am 
Offline

Joined: September 7th, 2011, 6:43 pm
Posts: 4
Hi,

I want to execute this command:

Code:
C:\Prog1\odbcbin "DSN=ZGH DS1" "Select nr from table" > C:\1.txt


The file 1.txt is created with the correct query result. At the cmd promt there is an other info output - perhaps the exe returns an error - I don't know.

Now I want to execute the same command with autohotkey:

Code:
exec := "C:\Prog1\odbcbin ""DSN=ZGH DS1"" ""Select nr from table"" > C:\1.txt"

runwait %exec%


I see that the cmd window opens with the query result too but after it closes the file 1.txt was not created. So I need help for the correct syntax to pipe the output into a file.

Thank You.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 15th, 2011, 12:57 pm 
Offline

Joined: May 21st, 2010, 1:08 pm
Posts: 5
Hi,

I think your attempt passes the ">" and the "C:\1.txt" as parameters directly to the program.
If you explicit run the cmd.exe it works.

Run
Quote:
When running a program via Comspec (cmd.exe) -- perhaps because you need to redirect the program's input or output -- if the path or name of the executable contains spaces, the entire string should be enclosed in an outer pair of quotes. In the following example, the outer quotes are shown in red and all the inner quotes are shown in black:

Run %comspec% /c ""C:\My Utility.exe" "param 1" "second param" >"C:\My File.txt""


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 15th, 2011, 1:45 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
This raises an excellent question that has always bugged me...

Does anyone know the rules or documentation behind HOW THE HECK WINDOWS INTERPRETS RUN STRINGS???

Sometimes when zipping something in a script I'll have to use like

"C:\whatever\wzzip.exe" "New File.zip" "S:\ource\folder\full\path\"

Sometimes it seems to go off without a hitch without quotes, sometimes the whole string needs to be quoted...

Is this specific to what I'm working with? I'd just like to know if this is another insane thing that should be a standard but isn't or if I missed the logic behind what was intended.

Edit: There's actually another thread about almost that same thing! http://www.autohotkey.com/forum/viewtopic.php?t=79988


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 15th, 2011, 5:00 pm 
Offline

Joined: September 7th, 2011, 6:43 pm
Posts: 4
hippibruder wrote:
Hi,

I think your attempt passes the ">" and the "C:\1.txt" as parameters directly to the program.
If you explicit run the cmd.exe it works.


Thank you, that works.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Amandaville, BrandonHotkey, chaosad, Yahoo [Bot] and 18 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group