# System(), syscall(), and Shells

**URL:** <https://www.ruby-forum.com/t/system-syscall-and-shells/122955>\
**Category:** Ruby\
**Created:** [December 13, 2007, 12:23am UTC](https://www.ruby-forum.com/t/system-syscall-and-shells/122955 "2007-12-13T00:23:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![thefed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@thefed](https://www.ruby-forum.com/u/thefed)\
**Post date:** [December 13, 2007, 12:23am UTC](https://www.ruby-forum.com/t/system-syscall-and-shells/122955/1 "2007-12-13T00:23:11Z")

</div>

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 B.  
--------------------------------------------|  
If you’re not living on the edge,  
then you’re just wasting space.

---

<div class="post-metadata">

**Author:** ![thefed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@thefed](https://www.ruby-forum.com/u/thefed)\
**Post date:** [December 13, 2007, 12:48am UTC](https://www.ruby-forum.com/t/system-syscall-and-shells/122955/2 "2007-12-13T00:48:58Z")

</div>

On Dec 12, 6:21 pm, thefed [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 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?

---

<div class="post-metadata">

**Author:** ![thefed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@thefed](https://www.ruby-forum.com/u/thefed)\
**Post date:** [December 13, 2007, 1:17am UTC](https://www.ruby-forum.com/t/system-syscall-and-shells/122955/3 "2007-12-13T01:17:06Z")

</div>

On Dec 12, 2007, at 6:46 PM, Trans wrote:

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

subscribe to the mailing list!

removed\_email\_address@domain.invalid

-Ari

---

<div class="post-metadata">

**Author:** ![thefed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@thefed](https://www.ruby-forum.com/u/thefed)\
**Post date:** [December 13, 2007, 4:34pm UTC](https://www.ruby-forum.com/t/system-syscall-and-shells/122955/4 "2007-12-13T16:34:16Z")

</div>

On Wed, 12 Dec 2007 18:21:51 -0500, thefed wrote:

> 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

---

<div class="post-metadata">

**Author:** ![thefed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@thefed](https://www.ruby-forum.com/u/thefed)\
**Post date:** [December 13, 2007, 10:11pm UTC](https://www.ruby-forum.com/t/system-syscall-and-shells/122955/5 "2007-12-13T22:11:58Z")

</div>

On Dec 12, 2007 5:46 PM, Trans [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

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

I recommend joining the mailing list at  
[http://rubyunix.rubyforge.org/mailing\_lists/developers](http://rubyunix.rubyforge.org/mailing_lists/developers)

Also, feel free to drop by #rubyunix on freenode

Daniel Brumbaugh K.
