LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 01-16-2003, 01:57 PM   #1
kilobravo
LQ Newbie
 
Registered: Feb 2002
Posts: 18

Rep: Reputation: 0
script 'exit' command


This follows from an earlier thread about switching users from within a script. I am able to run my script as root, issue the 'su' command, run a few commands as the new user, and then I need to switch back to the root account. In a terminal I just type exit to accomplish this, however, the exit command in the script only halts the script, it doesn't actually switch back to the original user. Is there a way to accomplish this?
 
Old 01-16-2003, 02:05 PM   #2
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 197Reputation: 197
Have you tried possibly "logoff" ?
 
Old 01-16-2003, 02:20 PM   #3
kilobravo
LQ Newbie
 
Registered: Feb 2002
Posts: 18

Original Poster
Rep: Reputation: 0
I can't seem to find the logoff command. I tried it in a shell and it says the command isn't found. I tried it in the script, and it didn't work either.
 
Old 01-16-2003, 02:58 PM   #4
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 197Reputation: 197
I'm a twit, not logoff but maybe try logout..
 
Old 01-16-2003, 03:08 PM   #5
kilobravo
LQ Newbie
 
Registered: Feb 2002
Posts: 18

Original Poster
Rep: Reputation: 0
I tried that one as well. It says that this is not a login shell...use 'exit'. AHHHHH!!!! I'm stuck in an infinite loop!!
 
Old 01-16-2003, 03:17 PM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
a code example wouldn't go amiss. how are you executing these commands? if it's somethign like
Code:
su user -c 'command 1; command 2'
then the shell will expire after the commands have been executed anyway.
 
Old 01-16-2003, 03:19 PM   #7
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86; Gentoo PPC; Gentoo Sparc64; FreeBSD; OS X; Solaris
Posts: 3,731
Blog Entries: 4

Rep: Reputation: 65
If you can su to a user, can you not su back to root within the script?
 
Old 01-16-2003, 03:21 PM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
that would be very bad practise, creatnig additional depths of login when you don't need to.
 
Old 01-16-2003, 03:24 PM   #9
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86; Gentoo PPC; Gentoo Sparc64; FreeBSD; OS X; Solaris
Posts: 3,731
Blog Entries: 4

Rep: Reputation: 65
Sorry, I didn't realise the logins got nested like that.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
call another script and have the inital script exit mjtice Programming 1 09-11-2005 11:54 AM
X-windows exit command?... Minime80 Linux - Software 4 02-16-2005 09:31 PM
Invoke script on xsession exit? comp12345 Linux - Software 1 06-27-2004 10:27 PM
How to exit the less textfile command? dubbuk Linux - Newbie 4 05-03-2004 04:47 PM
How to exit from > in command prompt ? FinnGnome Linux - Newbie 6 05-09-2003 02:50 PM


All times are GMT -5. The time now is 10:54 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration