Cannot logout from script.

Cannot logout from script.

Post by Michael Alber » Sun, 10 Sep 1995 04:00:00



I there,

I am trying to log myself out from a script, however am not able to do so.

The script is in cshell, but when using "logout" or "exec logout" it doesn't
log me off, it simply replies "Not Login Shell", is there any way around this?

I am fairly new in writing scripts, so please bare with me!

Thanks,

Michael
--

                ~/~~~  
               ` O-O '
                  |
                  o        |  |  |
  _----------ooO ----Ooo   |  |  |
 |   ___________________\  ________      
 |  /        Michael Albe\ \____   -

 | |       XImage Corpora\  /com  | |
 |  \_____________________\ \tion | |
  \________________________\ \___/  |
              _|_| |_|        \____/  
             (___) (_)                

  _________________________________________________________________
 /_________________________________________________________________\
| ThEsE CoMmEnTs AnD oPiNiOnS aRe MiNe, MiNe I TeLl Ya, AnD NoThInG |
| tO dO WiTh My EmPlOyEr WhAtSoEvEr. BLAH BLAH BLAH BLAH BLAH       |
 -------------------------------------------------------------------

 
 
 

Cannot logout from script.

Post by Abhijit Devastha » Sun, 10 Sep 1995 04:00:00


: I there,
:
: I am trying to log myself out from a script, however am not able to do so.
:
: The script is in cshell, but when using "logout" or "exec logout" it doesn't
: log me off, it simply replies "Not Login Shell", is there any way around this?
:
: I am fairly new in writing scripts, so please bare with me!
:
: Thanks,
:
: Michael
: --

  You cannot just type logout from a shell script because the script runs
in a new shell that is started for the script. What u can do is to kill
the login shell. For that run 'ps' and get the pid for 'csh' using grep
or something similar. Use kill -9 <pid> to kill it. If you start xwindows
after login  then you will have to get out of that first. For that
do 'ps' within ur script first and kill 'xlogout'.

Abhijit.

 
 
 

Cannot logout from script.

Post by Timothy J. Luom » Mon, 11 Sep 1995 04:00:00


        I am trying to log myself out from a script, however am
        not able to do so.

        The script is in cshell, but when using "logout" or "exec
        logout" it doesn't log me off, it simply replies "Not Login
        Shell", is there any way around this?

you need to 'source' your script, rather than running it:

ie

rather than
#!/bin/csh -f

echo "Goodbye!"
logout
#end

your script should be

echo "Goodbye!"
logout

and you should run it by typing

source NameOfScript

that should do it!

When you 'source' something it runs as if you typed it into the command  
line, rather than being executed in its own shell.  This could be useful  
in your .cshrc as well.  Say you want to put all your aliases in a  
separate file from .cshrc.  You could put them all in a file called  
~/.csh-aliases

and add this to .cshrc:

source ~/.csh-aliases

TjL
--

NeXT 3.2 m68k                          Another convert to the Z-Shell
MIME & NeXTMail OK but remember I'm using PPP, so big email = trouble
"If I  understood the man page, I wouldn't have asked the question."

 
 
 

Cannot logout from script.

Post by St Nick » Mon, 11 Sep 1995 04:00:00


Do not try to run the script with something like:

sh script

try instead

exec script

It works on both my Altos Xenix 3.7  and Altos UNIX

good luck John


 
 
 

Cannot logout from script.

Post by clapoi.. » Tue, 12 Sep 1995 04:00:00


I was successful in doing this by haning on to the parent pid. in sh it's $$ so I did something like this
in .profile :
INITPROC=$$
export INITPROC  ( get the pid of the parent process)

Then to do the logout from a menu I did :

kill -9 $INITPROC

In my case im running this from a menu so all the childprocesses have ended.  I'm new to this but I undestand that if all the childen
aren't dead then ther could be problems >

 
 
 

Cannot logout from script.

Post by clapoi.. » Tue, 12 Sep 1995 04:00:00


I was successful in doing this by* on to the parent pid. in sh it's $$ so I did something like this
in .profile :
INITPROC=$$
export INITPROC  ( get the pid of the parent process)

Then to do the logout from a menu I did :

kill -9 $INITPROC

In my case im running this from a menu so all the childprocesses have ended.  I'm new to this but I undestand that if all the childen
aren't dead then ther could be problems >

Sorry I posted a followup to this on the wrong level of the thread.  This is new to me and I'm just getting the hang of it.

Regards

 chris

 
 
 

Cannot logout from script.

Post by Michael Alber » Tue, 12 Sep 1995 04:00:00


Thanks Timothy,

It certainly worked, thank you.

That will make things work the way I would like to.

Thanks again.

Michael Albers

Quote:>you need to 'source' your script, rather than running it:

>ie

>rather than
>#!/bin/csh -f

>echo "Goodbye!"
>logout
>#end

>your script should be

>echo "Goodbye!"
>logout

>and you should run it by typing

>source NameOfScript

>that should do it!

>When you 'source' something it runs as if you typed it into the command  
>line, rather than being executed in its own shell.  This could be useful  
>in your .cshrc as well.  Say you want to put all your aliases in a  
>separate file from .cshrc.  You could put them all in a file called  
>~/.csh-aliases

>and add this to .cshrc:

>source ~/.csh-aliases

--

                ~/~~~  
               ` O-O '
                  |
                  o        |  |  |
  _----------ooO ----Ooo   |  |  |
 |   ___________________\  ________      
 |  /        Michael Albe\ \____   -

 | |       XImage Corpora\  /com  | |
 |  \_____________________\ \tion | |
  \________________________\ \___/  |
              _|_| |_|        \____/  
             (___) (_)                

  _________________________________________________________________
 /_________________________________________________________________\
| ThEsE CoMmEnTs AnD oPiNiOnS aRe MiNe, MiNe I TeLl Ya, AnD NoThInG |
| tO dO WiTh My EmPlOyEr WhAtSoEvEr. BLAH BLAH BLAH BLAH BLAH       |
 -------------------------------------------------------------------