The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script using awk works only as super user gjithin Shell Programming and Scripting 10 05-09-2008 09:30 AM
Sunsolaris shell script runs only as super user gjithin SUN Solaris 4 05-09-2008 08:47 AM
[Help] Give privilege to an ordinary user ibmer414 AIX 1 04-08-2008 02:56 PM
switching user from root to ordinary user sasia Shell Programming and Scripting 3 01-25-2008 10:25 PM
change user through shell script raviraushanjha UNIX for Dummies Questions & Answers 0 12-12-2005 03:11 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-04-2008
wrapster wrapster is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 193
How do i change to super user then revert back to ordinary user ,using shell script?

Hi all,

I am trying to eject the cdrom from a livecd after certain stage...
Now assuming that it is possible to eject,please consider my issue!!!

The OS boots into a regular user by default...so i am unable to use the eject command to push out the drive...
However if i try pfexec eject it works....but then again it works only when the system is completely up and running not at some intermittent stage in the boot process.

How do i change the my id to a Superuser then execute the eject command ,then once the eject is done with, i would like to revert back to the ordinary user?
Secondly this code should be incorporated into one of the boot scripts,
So that after a certain stage during the boot, the drive automatically ejects......

How do i do it.....

PS:i urge you to consider that ejecting the media on a livecd is possible.

Thanks
  #2 (permalink)  
Old 06-04-2008
nua7 nua7 is offline
Registered User
  
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 353
You can try using sudo with the eject command , without password.sudo works like a charm!
  #3 (permalink)  
Old 06-04-2008
scarfake scarfake is offline
Registered User
  
 

Join Date: May 2008
Posts: 43
put the user that should change to superuser into the /etc/sudoers file.
then run sudo with the --preserve-environment flag so you can use your varibales that you set under the first user also in the superuser. then exit from su mode with exit
  #4 (permalink)  
Old 06-04-2008
wrapster wrapster is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 193
i am using a flavor of solaris...
There is no command called sudo..
If i have to enter as super user then i will use
su - <account name>
will take you to the subsequent account

But i did look up the man pages and found a way out!!!
bash 3.2$: su - root -c eject
password: ******
<i am able to eject the drive>
bash3.2$:

and so i return back to default user......
so all my queries are solved...
However i am curious to know, since i have provided for a password, the system will ask for a passwd conformation...
But if dont ,then will it just skip the passwd thing, and proceed with ejecting??
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:19 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0