Call Perl script from Ruby

Hi,

I have a very basic Perl script (calls a nice CPAN library not available
in Ruby) that prints it output to the screen. In Ruby I call it like:

sql = vendor\\sql\\sql.pl "#{@question.sql}"

But I get the following error

Errno::ENOEXEC in Question#create
Exec format error - vendor\converters\sql\sql.pl “select * from
cdcol.cds”

When I call it from DOS it works perfectly. How can I fix this? And is
there an alternative for using ` (backquotes)? Thanks for the help.

Kind regards,

Nick

On Wed, Mar 08, 2006 at 11:00:42PM +0900, Nick S. wrote:

Exec format error - vendor\converters\sql\sql.pl “select * from
cdcol.cds”

When I call it from DOS it works perfectly. How can I fix this? And is
there an alternative for using ` (backquotes)? Thanks for the help.

IO.popen is one way to go. Here’s a quick example…

ls = IO.popen(“ls -ltr”, “r”)
puts ls.readlines

Kernel.exec should be the same as using the backquotes. If you need
something more robust, take a look at Open3.

Steve P.
[email protected]

Nick S. wrote:

Errno::ENOEXEC in Question#create
Exec format error - vendor\converters\sql\sql.pl “select * from
cdcol.cds”

try this:

sql = perl vendor\\sql\\sql.pl "#{@question.sql}"

Regards

robert

On Mar 8, 2006, at 10:01 AM, Steve P. wrote:

Kernel.exec should be the same as using the backquotes

Eeek! It is certainly not the same as using backquotes. exec
replaces the currently running process with its argument, he’d
never return to ruby to do additional processing.

Slightly OTT, I accidently ran a perl script with:

ruby script.pl

The other day, and it executed fine!!!

Look at them gem called “session”. It’s nice for executing processes.

It worked beautifully, thanks Robert. I’m also going to take a look at
popen, I say it used in another program and it looks promising.

Kind regards,

Nick

Robert K. wrote:

try this:

sql = perl vendor\\sql\\sql.pl "#{@question.sql}"

Regards

robert

Hello Robert,

I am newbe, and I get in trouble with special character ‘->’
e.g :

use Test::WWW::Mechanize;
my $mech = Test::WWW::Mechanize->new( );
$mech->get_ok( ‘http://search.cpan.org/’ );

How can we deal with this character.

your help is very appriciated

Hiep

On Mar 9, 2006, at 4:27 AM, Rob Pitt wrote:

Slightly OTT, I accidently ran a perl script with:

ruby script.pl

The other day, and it executed fine!!!

Was it

print “Hello, world!\n”

?

I use
<> instead <>

and it works
BTW Thanks you