[S.u.S.E. Linux] executing multiple commands in a shell script
How can I execute a program and leave X cleanly in a shell script? What would I follow the program execution with to exit X?: #!/bin/sh exec program ??????close x and return to console??????? I even installed xtexit and tried : #!/bin/sh exec program exec xtexit but it would just exec the first program and stop. Appreciate a nudge in the right direction. -- ==================================================================== Michael Lankton <A HREF="http://tasteslikechicken.ml.org"><A HREF="http://tasteslikechicken.ml.org</A">http://tasteslikechicken.ml.org</A</A>> ==================================================================== - To get out of this list, please send email to majordomo@suse.com with this text in its body: unsubscribe suse-linux-e
Michael Lankton wrote:
How can I execute a program and leave X cleanly in a shell script? What would I follow the program execution with to exit X?:
[...]
I even installed xtexit and tried :
#!/bin/sh exec program exec xtexit
but it would just exec the first program and stop. Appreciate a nudge in the right direction.
That wouldn't work because 'exec' executes your program but never returns, because it replaces the shell with the new process. If you want your script to execute 'program' and then 'xtexit', your script should be something like this: #!/bin/sh program exec xtexit o that 'xtexit' gets run after 'program'. Hope it helps, Bernardo. - To get out of this list, please send email to majordomo@suse.com with this text in its body: unsubscribe suse-linux-e
Thanks Bernardo and Bodo, that's exactly what I wanted. Bernardo Reino wrote:
That wouldn't work because 'exec' executes your program but never returns, because it replaces the shell with the new process. If you want your script to execute 'program' and then 'xtexit', your script should be something like this:
#!/bin/sh program exec xtexit
so that 'xtexit' gets run after 'program'.
Hope it helps,
Bernardo.
-- ==================================================================== Michael Lankton <A HREF="http://tasteslikechicken.ml.org"><A HREF="http://tasteslikechicken.ml.org</A">http://tasteslikechicken.ml.org</A</A>> ==================================================================== - To get out of this list, please send email to majordomo@suse.com with this text in its body: unsubscribe suse-linux-e
Hi! Trying to kill the keyboard, satan3@home.com produced:
How can I execute a program and leave X cleanly in a shell script? What would I follow the program execution with to exit X?:
#!/bin/sh exec program exec xtexit
but it would just exec the first program and stop. Appreciate a nudge in the right direction.
Well, it's described in the manual (man bash --> "exec "), so its a feature. Try #! /bin/sh /path/program /path/xtexit which will block the shell, as long as program is running. If program detaches or ends (it looks the same for the shell, the process dies --- detaching means a forked child lives on), xtexit will be run. Note that you do not want /path/program & for obvious reasons, and giving the path almost never hurts. -Wolfgang PS: The 'logout'-Button-method uses exec: Login starts a (non-interaktive) shell, which starts all the nice programs and is thus (grand)*father to everything you run: WM, xclock, xterms etc. Then it execs xlogout, which gets the (grand)*father position --- it dies after a mouse click. Thus, everything you own (except nohup etc.) is closed: #! /bin/sh Proggie_1 & Proggie_2 & Proggie_3 & exec xlogout -- PGP 2 welcome: Mail me, subject "send PGP-key". If you've nothing at all to hide, you must be boring. Unsolicited Bulk E-Mails: *You* pay for ads you never wanted. Is our economy _so_ weak we have to tolerate SPAMMERS? I guess not. - To get out of this list, please send email to majordomo@suse.com with this text in its body: unsubscribe suse-linux-e
<PRE> On 14-Jul-98 Michael Lankton wrote:
How can I execute a program and leave X cleanly in a shell script? What would I follow the program execution with to exit X?:
I even installed xtexit and tried :
#!/bin/sh exec program exec xtexit
but it would just exec the first program and stop. Appreciate a nudge in the right direction. --
I'm not sure about the rest of it but to get past "program" exec program & ---------------------------------- <A HREF="http://benham.net/index.html"><A HREF="http://benham.net/index.html</A">http://benham.net/index.html</A</A>> -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS d+(-) s:+ a29 C++$ UL++>++++ P+++$ L++>++++ E? W+++$ N+(-) o? K- w+++$(--) O M-- V- PS-- PE++ Y++ PGP++ t+ 5 X R+ !tv b++++ DI+++ D++ G++>G+++ e h+ r* y+ ------END GEEK CODE BLOCK------ ---------------------------------- </PRE> <A HREF="pgp00000.pgp"> PGP signature</A></P>
The Gecko wrote:
On 14-Jul-98 Michael Lankton wrote:
How can I execute a program and leave X cleanly in a shell script? What would I follow the program execution with to exit X?:
I even installed xtexit and tried :
#!/bin/sh exec program exec xtexit
but it would just exec the first program and stop. Appreciate a nudge in the right direction.
Why do you use 'exec' ? man bash: ... exec [-cl] [-a name] [command] [arguments] If command is specified, it replaces the shell. No new process is created. The arguments become the arguments to command. If the -l option is sup plied, the shell places a dash in the zeroth arg passed to command. This is what login(1) does. The -c option causes command to be executed with an empty environment. If -a is supplied, the shell passes name as the zeroth argument to the executed command. If command cannot be executed for some reason, a non-interactive shell exits, unless the shell option execfail is enabled, in which case it returns failure. An interactive shell returns failure if the file cannot be executed. If command is not specified, any redirections take effect in the current shell, and the return status is 0. ... Try to do #!/bin/sh program & xtexit or (if you really want to use 'exec'): #!/bin/sh ( exec program ) xtexit Ciao, BB -- Bodo Bauer S.u.S.E., LLC fon +1-510-835 7873 bb@suse.de 458 Santa Clara Avenue fax +1-510-835 7875 <A HREF="http://www.suse.com"><A HREF="http://www.suse.com</A">http://www.suse.com</A</A>> Oakland CA, 94610 USA - To get out of this list, please send email to majordomo@suse.com with this text in its body: unsubscribe suse-linux-e
participants (5)
-
bb@suse.com
-
gecko@benham.net
-
satan3@home.com
-
uc184@estud.unican.es
-
weissel@jupiter.ph-cip.uni-koeln.de