12-12-2005
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 permission to restart the process.
i tried using SU command it prompts me for the password. expect is not installed so was not able to use it. i even tried setting the SUID bit of the script and running the script as
su - user -c "/path/test.sh
here it starts asking for the roots password
the script is:
#!/bin/sh
var1=`ps -ef | grep -v grep | grep ravi | awk '{print $2}'`
echo $var1
if [ -z $var1 ]
then
echo "The Process is Running"
else
xx=`whoami`
echo $xx
cwd=`cd /user/bin`
pwd=`pwd`
echo $pwd
`su - user`
`ravi`
xx=`whoami`
echo $xx
prrestart=`/ravi/admin/KickWatchdog -restart`
echo "You win"
fi
echo $vasr1
echo 'ravi'
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
is it possible to chnage the user in a shell script?
i would like to create a script with should make some actions on the host which needs root permissions.
i want do give the user which should start the script the root permissions.
so is it possible to make a command in the script... (2 Replies)
Discussion started by: scottl
2 Replies
2. Shell Programming and Scripting
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)
Discussion started by: wrapster
3 Replies
3. Shell Programming and Scripting
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
4. Shell Programming and Scripting
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)
Discussion started by: bobbasystem
2 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I am new for solaris...
how can we change default shell for any user and how to check that which shall currently we are in...... (1 Reply)
Discussion started by: lalit21984
1 Replies
6. Shell Programming and Scripting
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
7. UNIX for Dummies Questions & Answers
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
8. Linux
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)
Discussion started by: taifurakhand
3 Replies
9. Shell Programming and Scripting
I would like to replicate the functionality of chsh (or passwd -e) by awk.
This is what I got so far, but I think there should be an easier way to search and replace field $7 only for lines beginning with user_name:
awk -v user_name="$user_name" -v new_shell="$new_shell" -F: '$1 == user_name {... (2 Replies)
Discussion started by: nomad84
2 Replies
10. Shell Programming and Scripting
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... (6 Replies)
Discussion started by: SkySmart
6 Replies
LEARN ABOUT SUNOS
delete-profiler
asadmin-delete-profiler(1AS) User Commands asadmin-delete-profiler(1AS)
NAME
asadmin-delete-profiler, delete-profiler - deletes the profiler element
SYNOPSIS
delete-profiler --user admin_user [--password admin_password] [--host localhost] [--port 4848] [--secure|-s] [--passwordfile filename]
[--terse=false] [--echo=false] [--interactive=true]
Deletes the profiler element. A server instance is tied to a particular profiler by the profiler element in the Java configuration. Chang-
ing a profiler requires you to restart the server.
This command is supported in remote mode only.
OPTIONS
--user authorized domain application server administrative username.
--password password to administer the domain application server.
--host machine name where the domain application server is running.
--port port number of the domain application server listening for administration requests.
--secure if true, uses SSL/TLS to communicate with the domain application server.
--passwordfile file containing the domain application server password.
--terse indicates that any output data must be very concise, typically avoiding human-friendly sentences and favoring well-
formatted data for consumption by a script. Default is false.
--echo setting to true will echo the command line statement on the standard output. Default is false.
--interactive if set to true (default), only the required password options are prompted.
Example 1: Using delete-profiler
asadmin> delete-profiler --user admin --passwordfile passwords.txt
--host localhost --port 4848
Deleted Profiler
Where: profiler is the deleted profile element.
EXIT STATUS
0 command executed successfully
1 error in executing the command
asadmin-create-profiler(1AS), asadmin-list-profiler(1AS)
J2EE 1.4 SDK March 2004 asadmin-delete-profiler(1AS)