Run perl script and capture the output

Hi all,

I need to run a perl script from Ruby and capture its output. I use the
following line in Ruby but it fails. Any input will be appreciated.

out=`perl c:\\Perl\\self\\back1\.pl`

Li

···

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

maybe you can try to use an absolute path to 'perl'.

···

2006/12/20, Li Chen <chen_li3@yahoo.com>:

Hi all,

I need to run a perl script from Ruby and capture its output. I use the
following line in Ruby but it fails. Any input will be appreciated.

out=`perl c:\\Perl\\self\\back1\.pl`

Li

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

Li Chen wrote:

Hi all,

I need to run a perl script from Ruby and capture its output. I use the
following line in Ruby but it fails.

Define "fails". What happened?

Any input will be appreciated.

out=`perl c:\\Perl\\self\\back1\.pl`

Is this really the line you used? How about this instead:

out=`perl c:\\Perl\\self\\back1.pl`

Or, because I have no way to test your Windows syntax:

out=`perl c:/Perl/self/back1.pl`

Also, if Perl has been installed correctly and the Perl script is written
reasonably well, you shouldn't need the "perl" command in the line.

If these alternatives fail, you will have to run some tests, and work up to
the script.

Tests like this:

out = `perl -v`

See what this puts in the "out" variable.

···

--
Paul Lutus
http://www.arachnoid.com

Hi Paul,

Thank you very much.

They all work fine now. In order to capture the output
from Ruby I just need to "puts xxxx".

Another quick question: How to translate the codes
above using IO.popen. I read the related part of
IO.popen but I can't figure out how.

BTW I can't see your post and another post to my
question from the forum at Ruby talk. I think the
server might have some problems.

Once again thank you very much,

Li

BTW I can't see you reply on the forum at Ruby-talk. I
think the server might have some problems.

···

--- Paul Lutus <nospam@nosite.zzz> wrote:

out=`perl c:\\Perl\\self\\back1.pl`

out=`perl c:/Perl/self/back1.pl`

out = `perl -v`

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around

see here for samples
http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_threads.html#UI

  robert

···

On 20.12.2006 08:56, chen li wrote:

Another quick question: How to translate the codes
above using IO.popen. I read the related part of
IO.popen but I can't figure out how.