calling Perl script from Ruby

P

Peter Michaux

Hi,

I have a Perl script that takes an input and outputs a string. I would
like to call this Perl script from my Ruby script and have the string
appear in my Ruby script after.

I was thinking I would use the command line of my system as the middle
man. Looking at Ruby's Kernel#system it only returns true or false if
the command is found and ran successfully or not. I would like to get
that string instead of true if possible.

I am hoping to avoid complicated things like having the Perl write to a
file and then read that file into Ruby.

Any suggestions?

Thank you,
Peter
 
E

Esteban Manchado Velázquez

--98e8jtXdkpgskNou
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi,
=20
I have a Perl script that takes an input and outputs a string. I would
like to call this Perl script from my Ruby script and have the string
appear in my Ruby script after.
[...]
Any suggestions?

Just do:

output =3D `perl myperlscript.pl arg1 arg2`

That should do the trick. You also have open3 and others, if you want more
fine-grained control of input and outputs.

HTH,

--=20
Esteban Manchado Vel=E1zquez <[email protected]> - http://www.foton.es
EuropeSwPatentFree - http://EuropeSwPatentFree.hispalinux.es

--98e8jtXdkpgskNou
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFFOmA0hYgK5b1UDsERAlnFAJ9sBl0oOh62dzY1yKvCBEej9rkcBwCeKaY5
hrAToi/qW6468+WBK+MwIC0=
=jDIv
-----END PGP SIGNATURE-----

--98e8jtXdkpgskNou--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top