LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
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
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
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,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
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,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

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


Reply



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
How to exit the less textfile command? dubbuk Linux - Newbie 7 03-31-2018 10:29 AM
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 from > in command prompt ? FinnGnome Linux - Newbie 6 05-09-2003 02:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:01 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration