system(), syscall(), and Shells

T

thefed

Hello all

I have a rather quick question.

As a part of the ruby unix team, we need to be able to execute
commands. One way to do this is through system. The other way is
through syscall.

First: does a call of system() open up a new process in the current
shell or does it make a system call? I tested this out with this
command:

system('cat csh.cshrc | wc') and got back a legitimate response. I'm
assuming, since I used pipelines, that this gets opened in a new
shell. I am asking here just to be safe.

Second: How exactly do I use syscall() in Ruby? Partically using
syscall for the exec command. I could get write to work, but not
exec. Help?

I have researched using syscall, and have only found documentation
for using it in C. C != Ruby # => true

Any help will be greatly appreciated.
Please notice the use of future instead of future conditional. This
means that ALL help will be appreciated. Not just some.

Thanks,
Ari Brown
--------------------------------------------|
If you're not living on the edge,
then you're just wasting space.
 
T

Trans

Hello all

I have a rather quick question.

As a part of the ruby unix team, we need to be able to execute
commands. One way to do this is through system. The other way is
through syscall.

How does one join/observe the unix ruby team?
 
K

Ken Bloom

Hello all

I have a rather quick question.

As a part of the ruby unix team, we need to be able to execute commands.
One way to do this is through system. The other way is through syscall.

First: does a call of system() open up a new process in the current
shell or does it make a system call? I tested this out with this
command:

system('cat csh.cshrc | wc') and got back a legitimate response. I'm
assuming, since I used pipelines, that this gets opened in a new shell.
I am asking here just to be safe.

Second: How exactly do I use syscall() in Ruby? Partically using syscall
for the exec command. I could get write to work, but not exec. Help?

I have researched using syscall, and have only found documentation for
using it in C. C != Ruby # => true

Syscall in ruby works exactly like it does in C.

Ruby (ri Kernel#syscall)
Calls the operating system function identified by _fixnum_, passing
in the arguments, which must be either +String+ objects, or
+Integer+ objects that ultimately fit within a native +long+. Up to
nine parameters may be passed (14 on the Atari-ST). The function
identified by _fixnum_ is system dependent. On some Unix systems,
the numbers may be obtained from a header file called +syscall.h+.

C (man 2 syscall)
syscall() performs the system call whose
assembly language interface has the specified
number with the specified arguments. Symbolic
constants for system calls can be found in the
header file <sys/syscall.h>.

--Ken
 

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
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top