[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Calling Exec() in Windows versus UNIX

Matthew Williams

9/24/2007 6:17:00 PM

I have the following line in a small app:

exec("charting/RequestByProject.jar",params[:name]')

When run in a UNIX environment it works fine.

However, moving it over to Windows and trying to run:
exec("charting\RequestByProject.jar",params[:name]')

Returns nothing... But if I jump to the Windows command line and run:
RequestByProject.jar project

It runs fine.

Any thoughts why it's not executing from my Ruby code in Windows?
--
Posted via http://www.ruby-....

4 Answers

Marc Heiler

9/24/2007 6:24:00 PM

0

Matthew Williams wrote:
> I have the following line in a small app:
>
> exec("charting/RequestByProject.jar",params[:name]')
>
> When run in a UNIX environment it works fine.
>
> However, moving it over to Windows and trying to run:
> exec("charting\RequestByProject.jar",params[:name]')
>
> Returns nothing... But if I jump to the Windows command line and run:
> RequestByProject.jar project
>
> It runs fine.
>
> Any thoughts why it's not executing from my Ruby code in Windows?


Did you try with system() or `` instead? Or maybe IO.
And tried File.exist? on it too, to see if the path was working?

Last but not least, maybe it wasn't in the path. But if it can be found,
it should even work on Windows using something like
result = `RequestByProject.jar #{params[:name]}`
and peeking at the result, and the error code

Just some thoughts :)
--
Posted via http://www.ruby-....

Matthew Williams

9/24/2007 6:49:00 PM

0

Marc Heiler wrote:
> Matthew Williams wrote:
>> I have the following line in a small app:
>>
>> exec("charting/RequestByProject.jar",params[:name]')
>>
>> When run in a UNIX environment it works fine.
>>
>> However, moving it over to Windows and trying to run:
>> exec("charting\RequestByProject.jar",params[:name]')
>>
>> Returns nothing... But if I jump to the Windows command line and run:
>> RequestByProject.jar project
>>
>> It runs fine.
>>
>> Any thoughts why it's not executing from my Ruby code in Windows?
>
>
> Did you try with system() or `` instead? Or maybe IO.
> And tried File.exist? on it too, to see if the path was working?
>
> Last but not least, maybe it wasn't in the path. But if it can be found,
> it should even work on Windows using something like
> result = `RequestByProject.jar #{params[:name]}`
> and peeking at the result, and the error code
>
> Just some thoughts :)

@result = system("RequestByProject.jar "+params[:name]+"")

That did the trick.

I forgot about all the other system call methods... Thanks!
--
Posted via http://www.ruby-....

Joel VanderWerf

9/24/2007 7:21:00 PM

0

Matthew Williams wrote:
> exec("charting/RequestByProject.jar",params[:name]')

This works for me:

irb(main):004:0> exec "C:/Program Files/JGSoft/EditPadLite/EditPad.exe"

HTH.

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

Joel VanderWerf

9/24/2007 7:38:00 PM

0

Joel VanderWerf wrote:
> Matthew Williams wrote:
>> exec("charting/RequestByProject.jar",params[:name]')
>
> This works for me:
>
> irb(main):004:0> exec "C:/Program Files/JGSoft/EditPadLite/EditPad.exe"

This works too:

exec "C:/Program Files/JGSoft/EditPadLite/EditPad.exe", "C:/tmp/foo.txt"

Note the difference between #exec and #system: system blocks and returns
when the child is done, but exec causes the current process to be
replaced with the child.

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407