Hi,
I am working on a bash script in which I have to change user during the
processing of the script in order to check certain environment variables are
being correctly set for that user. Currently I am using the following
appraoch
change_user () {
NEW_USER=$1
echo "logging in as $NEW_USER."
su - $NEW_USER
#
#plus some error checking
#to ensure that the log in proceeds
#
}
change_user ismadm
#
#some commands to be run as ismadm user
#
the problem is that when I log in using the above approach is that the
script seems to be halted and the terminal presents a log in for the
$NEW_USER. I am looking for some method to login and run a few commands
without the user ever knowing (apart from supplying the password).
Thanks
Richard...
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!