Sponsored Content
Top Forums Shell Programming and Scripting How do i change to super user then revert back to ordinary user ,using shell script? Post 302202088 by wrapster on Wednesday 4th of June 2008 03:50:20 AM
Old 06-04-2008
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
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

change user through shell script

hi, my problem is that i am calling a script from my perl program. the script checks wether a particular process is running or not if the process is not running then it should start the process. the problem here is that the front end logs into backend with a user which does not have the... (0 Replies)
Discussion started by: raviraushanjha
0 Replies

2. Shell Programming and Scripting

switching user from root to ordinary user

Good day Guys!!! I am currently making a script in AIX, the script runs a SAS job, the owner of the script is the root, but the SAS jobs cannot be run by the root, as it should be run by a user 'sasia'. But inside the script, root creates a logfile, so what I need is just to su to sasia for the... (3 Replies)
Discussion started by: sasia
3 Replies

3. AIX

[Help] Give privilege to an ordinary user

I'm trying to give a non-root user the right to start IBM HTTP Server, the web server is listening on port 80, but for AIX, ports under 1024 are privilege ports which can be used only by root. /usr/IBMIHS/bin# ./apachectl start (13)Permission denied: make_sock: could not bind to address :::80... (1 Reply)
Discussion started by: ibmer414
1 Replies

4. Solaris

Sunsolaris shell script runs only as super user

Hi Friends, I am new to Sun solaris unix.I am facing problem while runing my kornshell script just as an ordinary user.The script works fine while i am working as a super user.the script just uses awk to check the first charcter of a file and then copies the file to another folder. Do i... (4 Replies)
Discussion started by: gjithin
4 Replies

5. Shell Programming and Scripting

Script using awk works only as super user

hi friends, I am a new Sun Solaris 10 user. I have the following script line=$(awk '{if(substr($0,1,1)!="#" && substr($0,1,1)!=";" && substr($0,1,1)!=" " && substr($0,1,1)!="/" && substr($0,1,1)!="*" && substr($0,1,1)!="\\" && length($0)!=0) ... (10 Replies)
Discussion started by: gjithin
10 Replies

6. Linux

grant root privileges to ordinary user

Hi, Is it possible to grant root privileges to an ordinary user? Other than 'sudo', is there some way under Users/Groups configuration? I want ordinary user to be able to mount, umount and use command mt. /Brendan (4 Replies)
Discussion started by: brendan76
4 Replies

7. UNIX for Dummies Questions & Answers

How to give an ordinary user the superuser (root) ID which is 0

How to give an ordinary user the superuser (root) ID which is 0 (9 Replies)
Discussion started by: sharaola
9 Replies

8. Shell Programming and Scripting

root user command in shell script execute as normal user

Hi All I have written one shell script for GPRS route add is given below named GPRSRouteSet.sh URL="www.google.com" VBURL="10.5.2.211" echo "Setting route for $URL for GPRS" URL_Address=`nslookup $URL|grep Address:|grep -v "#"|awk -F " " '{print $2}'|head -1` echo "Executing ... (3 Replies)
Discussion started by: mnmonu
3 Replies

9. Shell Programming and Scripting

Shell Script to change a user password using script

Hi Experts, I had tried to executes this script to change the user password through script: No lines in buffer #!/bin/ksh cat /etc/passwd | grep -v userid >> /tmp/pass.tmp1 cat /etc/passwd | grep userid >> /tmp/pass.tmp2 PASS1=`cat /tmp/pass.tmp2 | cut -d ":" -f2` PASS2=`q2w3e4r5` sed... (3 Replies)
Discussion started by: indrajit_renu
3 Replies

10. UNIX for Dummies Questions & Answers

Change user passwords using shell script

Hi, I want to change the password of unix users on a number of servers.My plan was to ssh to all the servers in a shell script and use the passwd command. I tried to do so but everytime i run it i get this error. ssh -x -n -l user1 host passwd Changing password for "user1" 3004-709 Error... (3 Replies)
Discussion started by: poojabhat
3 Replies
EJECT(1)							   User Commands							  EJECT(1)

NAME
eject - eject removable media SYNOPSIS
eject [options] device|mountpoint DESCRIPTION
Eject allows removable media (typically a CD-ROM, floppy disk, tape, JAZ, ZIP or USB disk) to be ejected under software control. The com- mand can also control some multi-disc CD-ROM changers, the auto-eject feature supported by some devices, and close the disc tray of some CD-ROM drives. The device corresponding to device or mountpoint is ejected. If no name is specified, the default name /dev/cdrom is used. The device may be addressed by device name (e.g. 'sda'), device path (e.g. '/dev/sda'), UUID=<uuid> or LABEL=<label> tags. There are four different methods of ejecting, depending on whether the device is a CD-ROM, SCSI device, removable floppy, or tape. By default eject tries all four methods in order until it succeeds. If device partition is specified, the whole-disk device is used. If the device or a device partition is currently mounted, it is unmounted before ejecting. OPTIONS
-a, --auto on|off This option controls the auto-eject mode, supported by some devices. When enabled, the drive automatically ejects when the device is closed. -c, --changerslot slot With this option a CD slot can be selected from an ATAPI/IDE CD-ROM changer. Linux 2.0 or higher is required to use this feature. The CD-ROM drive can not be in use (mounted data CD or playing a music CD) for a change request to work. Please also note that the first slot of the changer is referred to as 0, not 1. -d, --default List the default device name. -f, --floppy This option specifies that the drive should be ejected using a removable floppy disk eject command. -F, --force Force eject, don't check device type. -h, --help Print a help text and exit. -i, --manualeject on|off This option controls locking of the hardware eject button. When enabled, the drive will not be ejected when the button is pressed. This is useful when you are carrying a laptop in a bag or case and don't want it to eject if the button is inadvertently pressed. -p, --proc This option allow you to use /proc/mounts instead /etc/mtab. It also passes the -n option to umount(1). -q, --tape This option specifies that the drive should be ejected using a tape drive offline command. -m, --no-unmount The option tells eject to not try to unmount at all. -M, --no-partitions-unmount The option tells eject to not try to unmount another partitions on partitioned devices. If another partition is mounted the program will not attempt to eject the media. It will attempt to unmount only mountpoint or mounted device given on eject command line. -n, --noop With this option the selected device is displayed but no action is performed. -t, --trayclose With this option the drive is given a CD-ROM tray close command. Not all devices support this command. -T, --traytoggle With this option the drive is given a CD-ROM tray close command if it's opened, and a CD-ROM tray eject command if it's closed. Not all devices support this command, because it uses the above CD-ROM tray close command. -r, --cdrom This option specifies that the drive should be ejected using a CDROM eject command. -s, --scsi This option specifies that the drive should be ejected using SCSI commands. -v, --verbose Run in verbose mode; more information is displayed about what the command is doing. -V, --version Display program version and exit. -x, --cdspeed <speed> With this option the drive is given a CD-ROM select speed command. The speed argument is a number indicating the desired speed (e.g. 8 for 8X speed), or 0 for maximum data rate. Not all devices support this command and you can only specify speeds that the drive is capable of. Every time the media is changed this option is cleared. This option can be used alone, or with the -t and -c options. -X, --listspeed With this option the CD-ROM drive will be probed to detect the available speeds. The output is a list of speeds which can be used as an argument of the -x option. This only works with Linux 2.6.13 or higher, on previous versions solely the maximum speed will be reported. Also note that some drive may not correctly report the speed and therefore this option does not work with them. EXIT STATUS
Returns 0 if operation was successful, 1 if operation failed or command syntax was not valid. NOTES
Eject only works with devices that support one or more of the four methods of ejecting. This includes most CD-ROM drives (IDE, SCSI, and proprietary), some SCSI tape drives, JAZ drives, ZIP drives (parallel port, SCSI, and IDE versions), and LS120 removable floppies. Users have also reported success with floppy drives on Sun SPARC and Apple Macintosh systems. If eject does not work, it is most likely a limi- tation of the kernel driver for the device and not the eject program itself. The -r, -s, -f, and -q options allow controlling which methods are used to eject. More than one method can be specified. If none of these options are specified, it tries all four (this works fine in most cases). Eject may not always be able to determine if the device is mounted (e.g. if it has several names). If the device name is a symbolic link, eject will follow the link and use the device that it points to. If eject determines that the device can have multiple partitions, it will attempt to unmount all mounted partitions of the device before ejecting (see --no-partitions-unmount). If an unmount fails, the program will not attempt to eject the media. You can eject an audio CD. Some CD-ROM drives will refuse to open the tray if the drive is empty. Some devices do not support the tray close command. If the auto-eject feature is enabled, then the drive will always be ejected after running this command. Not all Linux kernel CD-ROM driv- ers support the auto-eject mode. There is no way to find out the state of the auto-eject mode. You need appropriate privileges to access the device files. Running as root is required to eject some devices (e.g. SCSI devices). AUTHORS
Jeff Tranter <tranter@pobox.com> - original author. Karel Zak <kzak@redhat.com> and Michal Luscon <mluscon@redhat.com> - util-linux version. SEE ALSO
lsblk(8), findmnt(8), mount(8), umount(8) AVAILABILITY
The eject command is part of the util-linux package and is available from Linux Kernel Archive <ftp://ftp.kernel.org/pub/linux/utils/util- linux/>. Linux April 2012 EJECT(1)
All times are GMT -4. The time now is 05:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy