PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > Tcsh : no exit after script execution
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Tcsh : no exit after script execution

Réponse
 
LinkBack Outils de la discussion
Vieux 13/11/2007, 13h36   #1
pmaire@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Tcsh : no exit after script execution

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

  Réponse avec citation
Vieux 13/11/2007, 16h00   #2
Oscar del Rio
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Tcsh : no exit after script execution

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

  Réponse avec citation
Vieux 13/11/2007, 16h52   #3
pmaire@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Tcsh : no exit after script execution

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

  Réponse avec citation
Vieux 13/11/2007, 17h41   #4
Oscar del Rio
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Tcsh : no exit after script execution

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)
  Réponse avec citation
Vieux 14/11/2007, 00h40   #5
Maxwell Lol
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Tcsh : no exit after script execution

"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

  Réponse avec citation
Vieux 14/11/2007, 08h21   #6
pmaire@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Tcsh : no exit after script execution

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

  Réponse avec citation
Vieux 14/11/2007, 08h23   #7
pmaire@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Tcsh : no exit after script execution

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...

  Réponse avec citation
Vieux 14/11/2007, 15h34   #8
Oscar del Rio
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Tcsh : no exit after script execution

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



  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h19.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,21682 seconds with 16 queries