|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Good afternoon,
I would like to invoke tcsh in order to start a nested shell, and within this shell immediatly start a script. If i run " tcsh " I start a nested shell but not my script. If i run " tcsh myscript.csh" I start a nested shell that executes my script, but it exits after execution !! I would like that after the execution of myscript.csh, the nested shell does not exit and gives the user a prompt. Is this possible ?? Thanks for your Philippe |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
pmaire@gmail.com wrote:
> I would like to invoke tcsh in order to start a nested shell, and > within this shell immediatly start a script. > If i run " tcsh " I start a nested shell but not my script. > If i run " tcsh myscript.csh" I start a nested shell that executes my > script, but it exits after execution !! > I would like that after the execution of myscript.csh, the nested > shell does not exit and gives the user a prompt. "exec tcsh" at the end of myscript.csh |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On 13 nov, 17:00, Oscar del Rio <del...@mie.utoronto.ca> wrote:
> pma...@gmail.com wrote: > > I would like to invoke tcsh in order to start a nested shell, and > > within this shell immediatly start a script. > > If i run " tcsh " I start a nested shell but not my script. > > If i run " tcsh myscript.csh" I start a nested shell that executes my > > script, but it exits after execution !! > > I would like that after the execution of myscript.csh, the nested > > shell does not exit and gives the user a prompt. > > "exec tcsh" at the end of myscript.csh Hi, thanks for your quick answer! However, it does not work the way I want... This is my setup.csh file ------------ # If not in a slave interpreter, start a new interpreter if (! $?slave_tcsh) then echo "Starting slave interpreter..." tcsh -c "set slave_tcsh; source setup.csh" echo "Returning in master interpreter" exit endif echo "Running in slave interpreter" set toto=1 exec tcsh ------------- now, if i source mysetup.csh, I enter in the slave interpreter, and stay in it (this is what I want !), but if I type echo $toto I got an "undefined variable" error. The environment has not been kept because of the "exec tcsh". Too bad, setup.csh is a script to set the environment ;-) Any idea that might ? Philippe |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
pmaire@gmail.com wrote:
> echo "Running in slave interpreter" > set toto=1 > exec tcsh > ------------- > now, if i source mysetup.csh, I enter in the slave interpreter, and > stay in it (this is what I want !), but if I type > echo $toto > I got an "undefined variable" error. "set" statements are not exported, use "setenv" instead (and without '=') setenv TOTO 1 (conventionally env variables are upper case but it's not a requirement) |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
"pmaire@gmail.com" <pmaire@gmail.com> writes:
> > "exec tcsh" at the end of myscript.csh > > Hi, > thanks for your quick answer! > However, it does not work the way I want... > > This is my setup.csh file > ------------ > # If not in a slave interpreter, start a new interpreter > if (! $?slave_tcsh) then > echo "Starting slave interpreter..." > tcsh -c "set slave_tcsh; source setup.csh" try exec tcsh -c "set slave_tcsh; source setup.csh" > echo "Returning in master interpreter" > exit > endif > > echo "Running in slave interpreter" > set toto=1 > exec tcsh |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On 14 nov, 01:40, Maxwell Lol <nos...@com.invalid> wrote:
> "pma...@gmail.com" <pma...@gmail.com> writes: > > > "exec tcsh" at the end of myscript.csh > > > Hi, > > thanks for your quick answer! > > However, it does not work the way I want... > > > This is my setup.csh file > > ------------ > > # If not in a slave interpreter, start a new interpreter > > if (! $?slave_tcsh) then > > echo "Starting slave interpreter..." > > tcsh -c "set slave_tcsh; source setup.csh" > > try > > exec tcsh -c "set slave_tcsh; source setup.csh" > > > > > echo "Returning in master interpreter" > > exit > > endif > > > echo "Running in slave interpreter" > > set toto=1 > > exec tcsh- Masquer le texte des messages précédents - > > - Afficher le texte des messages précédents - This does not work as I want, because when the slave interpreter exits, the master is killed... I want to keep the master interpreter so that I can run a new slave interpreter with different parameters. Thanks for your answer anyway ! Philippe |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On 13 nov, 18:41, Oscar del Rio <del...@mie.utoronto.ca> wrote:
> pma...@gmail.com wrote: > > echo "Running in slave interpreter" > > set toto=1 > > exec tcsh > > ------------- > > now, if i source mysetup.csh, I enter in the slave interpreter, and > > stay in it (this is what I want !), but if I type > > echo $toto > > I got an "undefined variable" error. > > "set" statements are not exported, use "setenv" instead (and without '=') > > setenv TOTO 1 > > (conventionally env variables are upper case but it's not a requirement) Yes, but my script "setup.csh" is a setup script for a tool that I cannot modify. And it uses standard variables defined with set. I really need to stay in the same environment after the script's execution... |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
pmaire@gmail.com wrote:
> On 13 nov, 18:41, Oscar del Rio <del...@mie.utoronto.ca> wrote: >> pma...@gmail.com wrote: >>> echo "Running in slave interpreter" >>> set toto=1 >>> exec tcsh >>> ------------- >>> now, if i source mysetup.csh, I enter in the slave interpreter, and >>> stay in it (this is what I want !), but if I type >>> echo $toto > Yes, but my script "setup.csh" is a setup script for a tool that I > cannot modify. And it uses standard variables defined with set. > I really need to stay in the same environment after the script's > execution... > You might want to re-think the way you want to set it up, e.g. add "source setup.csh" to .cshrc or .tcshrc and simply run tcsh without any other options. tcsh will source .cshrc automatically, which in turn should source your setup.csh |
|
![]() |
| Outils de la discussion | |
|
|