[Gambas-user] Doubts in execute shell commands
Benoit Minisini
gambas at ...1...
Fri Nov 9 19:53:28 CET 2007
On vendredi 9 novembre 2007, ron wrote:
> On Friday 09 November 2007 09:26, Tomas Eroles i Forner wrote:
> > Hi!
> > Thanks for your help Ron.
> > It seems that GAMBAS does not like &.
> > The only way I've seen is using SHELL instead of EXEC, but it does not
> > works anyway, that is, I can see the graph, but only one or two seconds.
> >
> > Anybody could explain the difference?
>
> oops
>
> maybe the 3' parm must be "\&" for escaping the ampersand.
> Does it also not work with SHELL ( "gnuplot graph1.plt \&" ) ??
>
> Ron
>
>
Hmmm. A lot of confusion there...
SHELL run commands inside a "shell" (/bin/sh), i.e. it takes the string and
sends it directly to a shell.
EXEC run a process with arguments (this is the reason why it is run with a
string array).
The "&" is a shell thing, not a O.S. thing. As "|" (pipes), "<"/">"
(redirections) and all syntax you could find by typing "man bash". So when
you pass shell syntax to the EXEC command, they are sent directly to the
executed process without being interpreted.
So, "man system", "man bash" and "man execve" to understand the
differences. :-)
Now running a program from Gambas is different from running a program from a
X11 console. The X11 console runs its processes inside a "virtual terminal".
Gambas runs its processes through pipes.
Gambas can do the same thing, but not by default. You must use a special
syntax as explained on the wiki man pages: EXEC [...] FOR INPUT OUTPUT.
Note: a real terminal is the console you get when you type ALT-F1 -> ALT-F6.
Command-line processes usually checks its standard input, and behave
differently when they are run inside a terminal and when they aren't.
For more information, "man isatty", "man pipe", "man getpt", "man grantpt",
and the gbx_c_process.c source file of the Gambas interpreter. :-)
Regards,
--
Benoit Minisini
More information about the User
mailing list