[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

call a perl function from ruby

sayoyo Sayoyo

4/7/2006 1:46:00 PM

HI,

I have a lot of script written with perl, and we want to call those
script with our new ruby application. and we don't know how!!! Can
anyone tell us how should we do this????

Thanks you vbery much

Sayoyo

3 Answers

Chris Hulan

4/7/2006 3:01:00 PM

0


sayoyo@yahoo.com wrote:
> HI,
>
> I have a lot of script written with perl, and we want to call those
> script with our new ruby application. and we don't know how!!! Can
> anyone tell us how should we do this????
>
> Thanks you vbery much
>
> Sayoyo

You can run a system command via:
`perl myPerlScript.pl`

or check the system method

sayoyo Sayoyo

4/7/2006 3:20:00 PM

0

Hi,

Thanks for the information, but how can I get the results from our perl
script.???

actually, we find out that we can use this code:

obj = IO.popen("/usr/bin/perl hello_world.pl world", "w+")
obj.close_write
toto = obj.gets
obj.close
puts toto

but is there other way to do this?

sayoyo

Chris Hulan

4/7/2006 4:01:00 PM

0


sayoyo@yahoo.com wrote:
> Hi,
>
> Thanks for the information, but how can I get the results from our perl
> script.???
>
> actually, we find out that we can use this code:
>
> obj = IO.popen("/usr/bin/perl hello_world.pl world", "w+")
> obj.close_write
> toto = obj.gets
> obj.close
> puts toto
>
> but is there other way to do this?
>
> sayoyo

Well:

foo = `type readme.txt`

will put the contents of readme.txt into foo, so is good for grabbing
stdout from the external app

Or you can check out popen3 if you need separate acces to STDIN, STDOUT
and STDERR