LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   shell script + change shell && continue (https://www.linuxquestions.org/questions/programming-9/shell-script-change-shell-and-and-continue-293792/)

darkRoom 02-23-2005 06:36 AM

shell script + change shell && continue
 
Hi
Is it possible to have a script which will execute this:
Quote:

exec /bin/bash --login
and then continue the rest of this script in this new shell ? I read that exec never retruns success so im thinking no, but hey if theres a possibility . . .

thanks

bigearsbilly 02-23-2005 07:01 AM

dont think so.

hiteshmaisheri 02-23-2005 07:27 AM

hii,
if you rean the man page exec, it clearly states that it replaces the current shell
your can read the man page for the exec command it is as given below :
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 supplied, the shell places a dash at the begin-
ning of 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 can-
not be executed. If command is not specified, any redirections
take effect in the current shell, and the return status is 0.
If there is a redirection error, the return status is 1.
so it is no possible using exec command ...
you can write a c program fork a process and exec it using the scripts you want is the possiblity i seee...

Hitesh

darkRoom 02-23-2005 07:48 AM

ok thanks, that was what i was thinking,

keefaz 02-23-2005 09:05 AM

Why don't you set your first line of script with :
#!/bin/bash --login

darkRoom 02-23-2005 09:27 AM

Thats a good point but i think the way to go now is write a c program to hold what im doing together. Im just learning how shell scripts work and i have a task which chains together a number of scripts, i guess im finding out what can and can't be done with scripts

thanks

hiteshmaisheri 02-25-2005 02:50 AM

All the best .. do post as many questions as you can.. we will be happy to learn from your experiences and share each others knowledge and experiences...


All times are GMT -5. The time now is 11:59 PM.