The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How do i change to super user then revert back to ordinary user ,using shell script? wrapster Shell Programming and Scripting 3 06-04-2008 04:11 AM
script to change passwords for the same user on multiple servers stolz Shell Programming and Scripting 6 12-18-2007 09:08 AM
Change Password In A Shell Script pintu_asim Shell Programming and Scripting 6 06-29-2006 07:16 AM
change user in a shell scottl UNIX for Dummies Questions & Answers 2 08-28-2003 01:15 PM
How would I telnet & change user password automatically in a script darthur UNIX for Dummies Questions & Answers 4 01-14-2002 07:40 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-11-2005
Registered User
 

Join Date: Dec 2005
Posts: 2
Unhappy 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'

Reply With Quote
Google UNIX.COM
Forum Sponsor
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:02 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0