help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

system(), shell, & stderr.


From: John Eaton
Subject: system(), shell, & stderr.
Date: Mon, 28 Aug 1995 13:41:44 -0500

Francesco Potorti` <address@hidden> wrote:

: Why not:
: system("sh -c 'date 2>/dev/null'") --> Mon Aug 28 11:34:32 MET DST 1995
: 
: However, it looks like this is not necessary, because system() always
: uses sh, on the alpha precompiled binary I use.

Octave's system() function is implemented using a class derived from
the procbuf class in libg++, which implements a popen function.  The
code to exec the subprocess is

   _IO_execl("/bin/sh", "sh", "-c", command, NULL);

so your command should always be executed as a /bin/sh command,
provided that your system is Unix-like, you don't have a modified
version of libg++, and /bin/sh really is the Bourne shell.

I agree that it might be nice to make it possible to choose the shell,
but I don't think this is really necessary.  You should always be able
to do something like

  system (sprintf ("/bin/bash -c %s", command));

If your system really does use the login shell instead of /bin/sh for
Octave's system() function, can you try to debug why?

Thanks,

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]