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

···

--
Posted via http://www.ruby-forum.com/.

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 Peters
steve@fisharerojo.org

···

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

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.

Nick Snels wrote:

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"

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

···

--
Posted via http://www.ruby-forum.com/.

I use
<<perl script.pl>> instead <<ruby script.pl>>

and it works
BTW Thanks you

···

--
Posted via http://www.ruby-forum.com/.

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.

···

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

Kernel.exec should be the same as using the backquotes

Slightly OTT, I accidently ran a perl script with:

ruby script.pl

The other day, and it executed fine!!!!

···

On 8 Mar 2006, at 18:13, Logan Capaldo wrote:

On Mar 8, 2006, at 10:01 AM, Steve Peters 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.

Look at them gem called "session". It's nice for executing processes.

···

On 8 Mar 2006, at 18:13, Logan Capaldo wrote:

On Mar 8, 2006, at 10:01 AM, Steve Peters 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.

Was it

print "Hello, world!\n"

?

···

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!!!!