Trying to get a value from cshell script inside ruby

I

Irina Abramova

I am trying to run the c shell script inside ruby script.
Looks something like this:

csh_script = File.new(TemporaryFile.getFileName("test_csh"), w)
csh_script.puts("#!/bin/csh/")
csh_script.chmod(0555)
csh_script.puts(" ls -l | wc -l") #some command here
csh_script.puts("$STAT = $?")
csh_script.puts("exit($STAT)")
csh_script.close

#then call smth like this in order to execute the script

system(csh_script.path)


What I am trying to get is the value of the $STAT to get passed in to
the ruby script and assigned to some variable

I would appreciate any help
 
A

Axel Etzold

-------- Original-Nachricht --------
Datum: Sat, 7 Jun 2008 07:51:40 +0900
Von: Irina Abramova <[email protected]>
An: (e-mail address removed)
Betreff: Trying to get a value from cshell script inside ruby
I am trying to run the c shell script inside ruby script.
Looks something like this:

csh_script = File.new(TemporaryFile.getFileName("test_csh"), w)
csh_script.puts("#!/bin/csh/")
csh_script.chmod(0555)
csh_script.puts(" ls -l | wc -l") #some command here
csh_script.puts("$STAT = $?")
csh_script.puts("exit($STAT)")
csh_script.close

#then call smth like this in order to execute the script

system(csh_script.path)


What I am trying to get is the value of the $STAT to get passed in to
the ruby script and assigned to some variable

I would appreciate any help

Irina,

open3 (http://www.ruby-doc.org/stdlib/libdoc/open3/rdoc/index.html)

is designed for this kind of problem...

Best regards,

Axel
 

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

Forum statistics

Threads
474,159
Messages
2,570,881
Members
47,418
Latest member
NoellaXku

Latest Threads

Top