Discussion:
Doubts in execute shell commands
(too old to reply)
Tomas Eroles i Forner
2007-11-08 21:05:01 UTC
Permalink
Hi all!
I have some problems with EXEC and SHELL commands:
I would like to plot data with gnuplot from a Gambas application using:

SUB button1_Click()
EXEC ["gnuplot", "graph1.plt"] WAIT
END

where graph1.plt is a valid gnuplot file.

The problem is when GAMBAS executes this command a window appears in the
screen showing the graphs, but it disapears inmediately.
I've tried to add a pause command in the graph1.plt file and it works,
but only for a while, and I would like one of these solutions:
- the graph appears in a form but I don't know in which control (if
possible)
- the graph appears as a new window, but, the user can close this window

Any idea?

thanks in advance
Daniel Campos
2007-11-08 23:38:49 UTC
Permalink
Hi:

I think gnuPlot can draw on a image file instead of the X11 display,
so you could ask gnuPlot to draw in a file (a PNG file, for example),
and then load and display it in a PictureBox or DrawingArea control

Daniel
Post by Tomas Eroles i Forner
Hi all!
SUB button1_Click()
EXEC ["gnuplot", "graph1.plt"] WAIT
END
where graph1.plt is a valid gnuplot file.
The problem is when GAMBAS executes this command a window appears in the
screen showing the graphs, but it disapears inmediately.
I've tried to add a pause command in the graph1.plt file and it works,
- the graph appears in a form but I don't know in which control (if
possible)
- the graph appears as a new window, but, the user can close this window
Any idea?
thanks in advance
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
ron
2007-11-09 04:19:07 UTC
Permalink
Post by Tomas Eroles i Forner
Hi all!
SUB button1_Click()
EXEC ["gnuplot", "graph1.plt"] WAIT
END
where graph1.plt is a valid gnuplot file.
The problem is when GAMBAS executes this command a window appears in the
screen showing the graphs, but it disapears inmediately.
I've tried to add a pause command in the graph1.plt file and it works,
- the graph appears in a form but I don't know in which control (if
possible)
- the graph appears as a new window, but, the user can close this window
Any idea?
thanks in advance
As commandline "gnuplot graph1.plt &" starts a thread/job for it.

Try:
SUB button1_Click()
EXEC ["gnuplot", "graph1.plt", "&"] WAIT
END


Ron
Tomas Eroles i Forner
2007-11-09 08:26:20 UTC
Permalink
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?
Post by ron
Post by Tomas Eroles i Forner
Hi all!
SUB button1_Click()
EXEC ["gnuplot", "graph1.plt"] WAIT
END
where graph1.plt is a valid gnuplot file.
The problem is when GAMBAS executes this command a window appears in the
screen showing the graphs, but it disapears inmediately.
I've tried to add a pause command in the graph1.plt file and it works,
- the graph appears in a form but I don't know in which control (if
possible)
- the graph appears as a new window, but, the user can close this window
Any idea?
thanks in advance
As commandline "gnuplot graph1.plt &" starts a thread/job for it.
SUB button1_Click()
EXEC ["gnuplot", "graph1.plt", "&"] WAIT
END
Ron
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Tomas Eroles i Forner
2007-11-09 08:31:23 UTC
Permalink
YES, YES, YES, YEEEEEEEEEEEEEEEEEEESSSS !!!!

I've found it.

I have only to put a fucking

pause -1

as the last line of the plt file. Then, gnuplot waits until the user
closes the plot window
Post by Tomas Eroles i Forner
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?
Post by ron
Post by Tomas Eroles i Forner
Hi all!
SUB button1_Click()
EXEC ["gnuplot", "graph1.plt"] WAIT
END
where graph1.plt is a valid gnuplot file.
The problem is when GAMBAS executes this command a window appears in the
screen showing the graphs, but it disapears inmediately.
I've tried to add a pause command in the graph1.plt file and it works,
- the graph appears in a form but I don't know in which control (if
possible)
- the graph appears as a new window, but, the user can close this window
Any idea?
thanks in advance
As commandline "gnuplot graph1.plt &" starts a thread/job for it.
SUB button1_Click()
EXEC ["gnuplot", "graph1.plt", "&"] WAIT
END
Ron
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
ron
2007-11-09 08:49:30 UTC
Permalink
Post by Tomas Eroles i Forner
YES, YES, YES, YEEEEEEEEEEEEEEEEEEESSSS !!!!
I've found it.
I have only to put a fucking
pause -1
as the last line of the plt file. Then, gnuplot waits until the user
closes the plot window
Does gnuplot close the window always if not used with gambas, but standalone ?

If not then it sounds stupid for me to add pause -1 in every *.plt file
you get from others and must sound back.

Good to do as temporary solution but gambas should handle it the same
as any other application started from inside gambas and stay open forever.

Ron
ron
2007-11-09 08:43:57 UTC
Permalink
Post by Tomas Eroles i Forner
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
Benoit Minisini
2007-11-09 18:53:28 UTC
Permalink
Post by ron
Post by Tomas Eroles i Forner
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
Fabien Bodard
2007-11-09 20:49:09 UTC
Permalink
Post by Benoit Minisini
Post by ron
Post by Tomas Eroles i Forner
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,
Hey Benoit... is it say at same in the wiki doc ?... if not can you put it
Continue reading on narkive:
Loading...