Tcsh : no exit after script execution

Tcsh : no exit after script execution

am 13.11.2007 14:36:19 von pmaire

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 help
Philippe

Re: Tcsh : no exit after script execution

am 13.11.2007 17:00:53 von Oscar del Rio

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

Re: Tcsh : no exit after script execution

am 13.11.2007 17:52:44 von pmaire

On 13 nov, 17:00, Oscar del Rio 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 help ?
Philippe

Re: Tcsh : no exit after script execution

am 13.11.2007 18:41:23 von Oscar del Rio

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)

Re: Tcsh : no exit after script execution

am 14.11.2007 01:40:54 von Maxwell Lol

"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

Re: Tcsh : no exit after script execution

am 14.11.2007 09:21:04 von pmaire

On 14 nov, 01:40, Maxwell Lol wrote:
> "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=3D1
> > exec tcsh- Masquer le texte des messages pr=E9c=E9dents -
>
> - Afficher le texte des messages pr=E9c=E9dents -

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

Re: Tcsh : no exit after script execution

am 14.11.2007 09:23:52 von pmaire

On 13 nov, 18:41, Oscar del Rio 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...

Re: Tcsh : no exit after script execution

am 14.11.2007 16:34:49 von Oscar del Rio

pmaire@gmail.com wrote:
> On 13 nov, 18:41, Oscar del Rio 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