LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Solaris / OpenSolaris (http://www.linuxquestions.org/questions/solaris-opensolaris-20/)
-   -   How do i change to super user then revert back to ordinary user ,using shell script? (http://www.linuxquestions.org/questions/solaris-opensolaris-20/how-do-i-change-to-super-user-then-revert-back-to-ordinary-user-using-shell-script-646883/)

wrapster 06-04-2008 02:46 AM

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

jlliagre 06-04-2008 03:06 AM

I understand the live-cd is copied on RAM to allow ejection when done. How would the OS survive an ejection if it is depending on the live-cd media content at an earlier stage ?

What is the issue with pfexec ? It is the preferred way to run privileged commands as a regular user under Solaris.

wrapster 06-04-2008 03:44 AM

oh, so you want it out of me anyhow...
i have made this possible ...
The copy is done at an earlier stage itself...
Its not goin to wait till the gui is up for the copy to happen....
its now a part of the boot process ,meaning at a very primitive stage in the boot process itself the required files are copied to ram then on the cd becomes redundant....the remaining boot process including getting the gui will be done from ram

The pfexec program is used to execute commands with the
attributes specified by the user's profiles in the exec_attr file...

Could you think of a script now?

jlliagre 06-04-2008 06:19 AM

Sorry but I still don't understand where the problem lies. Do you want the cdrom to be ejected after the user logs in or before ?

What happens when you run the "eject cdrom" command ?

wrapster 06-04-2008 08:33 AM

i want the cdrom to be ejected after all files have been copied on RAM and at the point whrer the boot process begins from ram....

I have located the scripts that run after the copy is done, and i am incorporating this script in that file...

I really dont mind if the ejection happens as soon as the copy is done or when the gui is up...I just want it to happen ,thats all.

This is what i do,
Code:

echo "changing user, and ejecting " >/dev/msglog
exec su - root -c eject 2>/dev/msglog &
rpid=$!
wait $rpid
if [ $? -eq 0 ];then
echo "how was it??" >/dev/msglog
else
echo "unlucky soul" >/dev/msglog
fi

The strange thing is ,if i make a script out of it,and then execute it as an ordinary user...(once the gui is up)it works flawlessly,
There is a momentary change in the user and then the eject happens , then i am taken back to ord user...

But if i try using this in the boot script i get no errors but still the ejection wont happen??

If its easier to perform this action once the gui is up, am ready to give that a try as well...
Could you please specify as to,howi can do it?

Thanks

jlliagre 06-04-2008 10:52 AM

Why do you need to su in your copy script while I assume it already runs as root ?

Are you sure the cdrom filesystem is unmounted ? This is a mandatory prerequisite to media ejection.

swapanxavier 03-18-2009 03:37 AM

vlc run problem in f10
 
Quote:

Originally Posted by wrapster (Post 3174188)
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

pliz find me solution for running the vlc in f10


All times are GMT -5. The time now is 04:45 PM.