[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

dos %x{..} and my nUUbness

jOhn

7/13/2005 12:45:00 AM

Forgive my newbness :)

I am attempting to fire up a dos batch file, like for example startup a
jboss server instance.

In my *.rb script, I have this straight snippet:

puts %x{ c:/zone/jboss-4.0.1sp1/bin/run.bat -c node1 }

It works when I hard-code the path and args as in the sample above.

The path and path-args are hard-coded, because I can't figure out how to
pass in a variable and still get the server to start.

I have tried these:

puts %x{ printf "%s/bin/run.bat -c %s", serverPath, nodeName }
puts %x{ serverPath + "/bin/run.bat -c " + nodeName }
print %x{ serverPath + "/bin/run.bat -c " + nodeName }

and all kinds of others, so how to make the magic? How would you launch a
narly .bat file with a bunch of args and slashes passed along?

Also, is there a way to fire the DOS batch file and not have the script
pause for the process to finish ... so a non-blocking dos call?

Thanks.
-John A
1 Answer

Gavin Kistner

7/13/2005 1:04:00 AM

0

On Jul 12, 2005, at 6:44 PM, John Hager wrote:
> puts %x{ c:/zone/jboss-4.0.1sp1/bin/run.bat -c node1 }
>
> It works when I hard-code the path and args as in the sample above.
>
> The path and path-args are hard-coded, because I can't figure out
> how to
> pass in a variable and still get the server to start.

String interpolation works in many magical places.


path = "c:/zone/jboss-4.0.1sp1/bin/"
puts %x{ #{path}run.bat -c node1 }