i have a script that needs to be run as a specific user. lets call this specific user "skysmart".
sure, i can check the username of the person running the script and if it isn't "skysmart", simply abort with a descriptive error message. but then, that would require the user to have to "sudo su -" to skysmart and then rerun the script. i'd like to avoid this.
so, if this script is run as root, i want it to automatically "sudo su -" to "skysmart", and then run. without any further intervention from the user.
That's not going to work. su interrupts the execution of the shell script until you log out of the "su session".
If you are logged in as root all the time, and are using the script as a shortcut to execute commands as skysmart, that's not a good idea. Instead, just stay logged in as skysmart. When you need to do something special (usually not that often), login as root, or use sudo.
If you call the script with a relative pathname,
it is safer to replace $0 by the abolute path to this script.
Then I forgot an exec.
Then the fi somehow went to the end of the previous line
This User Gave Thanks to MadeInGermany For This Post:
Dear Forum,
In our organization 100 user is existing. Now i want to change password for 100 user in linux server. Pls help to write script for changing password.
Regads//
Taifur (3 Replies)
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)
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)
Hello there!
I need help:
I have this script:
#!/bin/bash
#chage to root user
sudo su
#Insert actual date
echo -n "Ingrese fecha actual: "
#Read the actual date
read fecha
#clean RAM memory
sync ; echo 3 > /proc/sys/vm/drop_caches ; swapoff -a && swapon -a
#backup opennms... (2 Replies)
I am trying to write a script to change passwords for the same user on multiple servers.
My environment runs purely ssh / scp not rsh / rcp and therefore coping using rcp is not an option.
I have been playing with expect to perform tasks but think there must be a better way.
Has anyone got... (7 Replies)
Hi,
I need to login into remote server and execute a shell script over there.
As of now i am making use of ssh command
ssh primUser@135.254.242.2 sh /poll.sh
I am logging in as primUser but unless i change the user to root the script execution on the remote machine is not possible.
... (5 Replies)
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... (3 Replies)
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)
I would like to create a script that logs into a list of several servers 50+ and changes my password all at once.
Every 60 days we are required to login to each system and change our passwords or else they expire and our login account is deleted.
I have an idea on how I could do this but... (4 Replies)