Can I write a batch script that will take an argument and pass it to another program like so:
>rubytest.bat "c:\path\to\script\to\test"
and have it run ruby.exe "c:\path\to\script\to\test"?
I have been searching for tutorials but can't find anything to do with passing arguments.
I want to run it with a batch script so I can stop the command line window from closing when the ruby program stops running. Are there other ways to do this?
Thanks
I've not done that with a batch command before...not sure if these ideas will help you but...
if you run ruby.exe from a cmd window (start-->windows-->run "cmd") the window remains open after ruby closes.
Are these programs you have written? If so there are simple ways to stop a "dos" program closing it's window when it finishes by forcing it to request a char input (i.e. press any key) before finishing?
Have you tried file redirection? Something like:
rubytest.bat > output.txt
ruby.exe < output.txt
More info at:
http://www.microsoft.com/resources/documen...h.mspx?mfr=true (http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=true)
QuoteOriginally posted by suicidal_monkey@Jun 15 2006, 03:20 PM
I've not done that with a batch command before...not sure if these ideas will help you but...
if you run ruby.exe from a cmd window (start-->windows-->run "cmd") the window remains open after ruby closes.
Are these programs you have written? If so there are simple ways to stop a "dos" program closing it's window when it finishes by forcing it to request a char input (i.e. press any key) before finishing?
[post=131821]Quoted post[/post]
[/b]
It's for debuging ruby scripts, so I get to see the error messages without the window closing. I want to use a batch script so I can call it from Notepad++
QuoteOriginally posted by BlueBall@Jun 15 2006, 03:24 PM
http://www.microsoft.com/resources/documen...h.mspx?mfr=true (http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=true)
Perhaps the CALL command is what you're after?
http://www.microsoft.com/resources/documen...l.mspx?mfr=true (http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/call.mspx?mfr=true)
QuoteOriginally posted by Wordan@Jun 15 2006, 03:26 PM
It's for debuging ruby scripts, so I get to see the error messages without the window closing. I want to use a batch script so I can call it from Notepad++
[post=131823]Quoted post[/post]
[/b]
In that case rubytest.bat "test script" > output.txt may do the trick? Worth a try?
Alternatively, see the bit about "Command Redirection Operators" in the link I gave - here is direct link.
http://www.microsoft.com/resources/documen...edirection.mspx (http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx)
I am thinking of something like this in particular:
QuoteThe & redirection operator duplicates output or input from one specified handle to another specified handle. For example, to send dir output to File.txt and send the error output to File.txt, type:
dir>c:\file.txt 2>&1
Thanks guys. My dos knowledge doesnt really extend beyond dir and cd. So a lot of that stuff looks very cryptic to me :unsure:
But I found what I wanted there, the whole %0 - %9 thing.
%0 is the path of the batch script and %1 and up are paremeters you added
Thus my rubytest.bat script is as follows:
@ECHO OFF
ruby %1
pause
A complex and thorough program that demonstrates my accomplished windows cmd skills very well.
Notepad++ calls rubytest "path to file im working on" when I press the run button and when my ruby script finishes runing or crashes with a bunch of errors I get to see them without the dos window disapearing untill I press the 'any key' as requested by the pause command in the batch script.
A satisified customer, thanks again :D
Glad to be of service :)
But don't really think I helped :blink: :roflmao:
For batch scripting I can advise you guys the following website.....
Batch scripting + examples (http://www.robvanderwoude.com)
Good luck.