LinuxQuestions.org
Help answer threads with 0 replies.
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-2011, 11:42 PM   #1
hamedhsn
Member
 
Registered: Feb 2010
Distribution: opensuse 11.2
Posts: 57

Rep: Reputation: 0
running script as command


i have a shell script which some of the lines should be running as root and some other not.the problem is that su is not practically work,it means it take root password from me but it does not run the commands in script.
the other problem is that there are some commands which should be run as normal user so how it exits from root mode and run that particular command. i tried exit in script file but it dos not work.
 
Old 01-17-2011, 02:03 AM   #2
Willy Gommel
LQ Newbie
 
Registered: Nov 2007
Posts: 28

Rep: Reputation: 1
running script as command

Quote:
Originally Posted by hamedhsn View Post
i have a shell script which some of the lines should be running as root and some other not.the problem is that su is not practically work,it means it take root password from me but it does not run the commands in script.
the other problem is that there are some commands which should be run as normal user so how it exits from root mode and run that particular command. i tried exit in script file but it dos not work.
Hello there! You sound frustrated.

Of course EXIT won't work with a script -- the command you need for that is ctrl-C, usually.

My question is: Why do you need to exit from ROOT mode in the middle of a script? Once you're in ROOT mode, it seems best to leave it that way until you have finished running the script. After all, if anyone can do a thing, ROOT can certainly do so too. Indeed, if you do terminate a script in ROOT or an individual user mode, the script is done anyway, as far as the computer is concerned -- in fact, you cannot change user while in the middle of a script!

As to SU ... it should leave you in root mode if it is there that you sign in. IOW, while you are in ROOT mode, all commands should be seen as coming from ROOT. It therefore would surprise me greatly if you in fact wrote me back to say that "SU did indeed run the ___ script." In fact, SU's sole purpose in life is to enable you to temporarily login as either another user or as ROOT. As such, it tends to function quite successfully. Have you carefully looked at your system's prompt? If you're logged in as ROOT, it seems to me that it should identify this fact with a "#"; otherwise, I believe that it normally uses a "$".

Good luck!!
 
  


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
running shell script: command not found tripat Red Hat 3 04-14-2010 01:21 PM
running a php script from command line leicaphotos Linux - Newbie 1 10-10-2008 01:24 PM
Running an awk script using command cks? vxc69 Programming 2 02-05-2008 01:54 PM
Error running command via shell script lowlifeish Linux - Software 2 08-31-2007 10:38 PM
running a command with args from a shell script KM3 Programming 3 10-19-2006 01:46 PM

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

All times are GMT -5. The time now is 07:32 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