From: gwtmp01@... Date: 2005-06-24T03:31:58+09:00 Subject: Re: Shell type On Jun 23, 2005, at 10:44 AM, Panich, Alexander wrote: > Under Linux, by default, method Kernel.system(command) (backticks as > well) executes command in the subshell of SH type. > > Is there a way to define another shell type (CSH for example) to > execute > there, or not? > Ruby is just providing an interface to the system() function defined by Posix, which defines system() to use "sh". There are two general options then: Use system() to run "sh" to run your interpreter: system('/bin/csh mycshellscript') or drop down a level and use Kernel#exec which interacts directly with the exec() family of system calls. Once you decide to do this, you probably have to start understanding how to use fork/exec together because exec by itself *replaces* the current running process. If you execute (in Ruby) exec "date" Then the ruby interpreter will be discarded by the current process and replaced with the /bin/date program, which will do it's thing and then exit. Instead you would probably want fork { exec "date" } which will cause the ruby process to fork. The new (child) process (Ruby) will then execute the block and be immediately replaced with the date executable when the Ruby interpreter calls the exec() system call. Meanwhile the original Ruby process continues executing. There are more details of course if you want the parent process to wait for the child and such. This is all Unix system programming stuff that Ruby provides via the Kernel and Process classes. There are lots of details to consider with exec to setup environment variables, argument lists, and what directories to search for the executable. See Kernel#exec or the man pages for the exec family of functions (execl/execlp/execle, etc.) If you haven't worked with fork/exec calls before they can be a little disorienting because of the way things are shared between the processes (fork) or programs (exec). Gary Wright