Particle Posted October 30, 2007 Share Posted October 30, 2007 I have a rather simple question. Say for I want to use the rundos command, yet in the command itself it requires quotations:_RunDos("FOR /F "eol=; tokens=1 delims=, " %%i in (%name%) do echo %%i:%port%>>"converted.txt"")Thats what it comes to look like in the Editor. Looks like to me it wouldn't work, but is there a way to make it work? Link to comment Share on other sites More sharing options...
Nahuel Posted October 30, 2007 Share Posted October 30, 2007 This has to work: _RunDos('FOR /F "eol=; tokens=1 delims=, " %%i in (%name%) do echo %%i:%port%>>"converted.txt"') Looks like it took you quite a while to post that. Link to comment Share on other sites More sharing options...
flyingboz Posted October 30, 2007 Share Posted October 30, 2007 as the help file states, autoit supports using either single or double quotes to delimit strings. In addition, the use of StringFormat() and other functions can greatly reduce the complexity required to properly render things such as the example above. Reading the help file before you post... Not only will it make you look smarter, it will make you smarter. Link to comment Share on other sites More sharing options...
LynnS Posted November 8, 2007 Share Posted November 8, 2007 I am having problems trying to get a command to run when using the _RunDOS command. It works fine when using RunWait, but fails with _RunDOS. Here is an example of some testing I've done and the results (in the comments): #include <process.au3> $cmd = @ProgramFilesDir & "\mypath\myprog.exe" RunWait($cmd) ; successful _RunDOS($cmd) ; fails $cmd2 = """" & @ProgramFilesDir & "\mypath\myprog.exe""" RunWait($cmd2) ; successful _RunDOS($cmd2) ; successful $cmd3 = """" & @ProgramFilesDir & "\mypath\postie.exe"" -host:smtpserver -to:toemail -from:fromemail -s:""Testing"" -msg:""Test"" -v:9" RunWait($cmd3) ; successful _RunDOS($cmd3) ; fails Any ideas? Link to comment Share on other sites More sharing options...
Joon Posted November 8, 2007 Share Posted November 8, 2007 (edited) haven't try it, please give a try. $cmd3 = "'" & @ProgramFilesDir & '\mypath\postie.exe -host:smtpserver -to:toemail -from:fromemail -s:"Testing" -msg:"Test" -v:9' & "'" Edited November 8, 2007 by Joon Link to comment Share on other sites More sharing options...
Developers Jos Posted November 8, 2007 Developers Share Posted November 8, 2007 try: $cmd3 = '""' & @ProgramFilesDir & '\mypath\postie.exe" -host:smtpserver -to:toemail -from:fromemail -s:"Testing" -msg:"Test" -v:9"' _RunDOS($cmd3); fails SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
RobertKipling Posted November 8, 2007 Share Posted November 8, 2007 For the record, Chr(34) is equivalent to the double-quote, in case you ever want to use single-quotes and double-quotes in the same line of code. You can say something like chr(34) & "Speak softly and carry a big stick." & chr(34) & " -- Teddy Roosevelt" Although the syntax is confusing, this statement is valid. It will produce the string: "Speak softly... big stick." -- Teddy Roosevelt. Link to comment Share on other sites More sharing options...
Tiger Posted November 8, 2007 Share Posted November 8, 2007 This is better #include <process.au3> $cmd = '"' & @ProgramFilesDir & '\mypath\myprog.exe"' RunWait($cmd) ; successful _RunDOS($cmd) ; successful My UDFs:- _RegEnumKey Link to comment Share on other sites More sharing options...
Developers Jos Posted November 8, 2007 Developers Share Posted November 8, 2007 All, its all the same using any of these: '"' & """" & Chr(34) & The essential item here is that when using @comspec which _RunDos() does, its is sometimes needed to enclose the whole command in Double Quotes. This is what i did with the proposed code.. SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
LynnS Posted November 9, 2007 Share Posted November 9, 2007 haven't try it, please give a try. $cmd3 = "'" & @ProgramFilesDir & '\mypath\postie.exe -host:smtpserver -to:toemail -from:fromemail -s:"Testing" -msg:"Test" -v:9' & "'" This one did not work. But it helped give me an idea to try. Thanks. Link to comment Share on other sites More sharing options...
LynnS Posted November 9, 2007 Share Posted November 9, 2007 try: $cmd3 = '""' & @ProgramFilesDir & '\mypath\postie.exe" -host:smtpserver -to:toemail -from:fromemail -s:"Testing" -msg:"Test" -v:9"' _RunDOS($cmd3); fails This one DID work. Thanks! Link to comment Share on other sites More sharing options...
LynnS Posted November 9, 2007 Share Posted November 9, 2007 All, its all the same using any of these:'"' & """" & Chr(34) &The essential item here is that when using @comspec which _RunDos() does, its is sometimes needed to enclose the whole command in Double Quotes.This is what i did with the proposed code..Thanks Jos, That's the explanation I was looking for. I just thought it would choke on doing the quote syntax like that. Interesting that they built the @comspec stuff to interpret it that way. Very good to know. Link to comment Share on other sites More sharing options...
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