How to handle command line options after switching the user in script

V

Viswanath Ediga

Guest
Hello All,

I am writing a script where I need to switch to another user in the middle of the script. It goes as below
Code:
echo "$HOME"
echo $1
id
sudo su - oradev << \EOF
echo "$HOME"
echo $1
id

When I run the above script as "sh script_name hello" out put is as below

Code:
/home/nagios
hello
uid=5003(nagios) gid=5003(nagios) groups=500(dba),5003(nagios)
/home/oradev
                           <####### I want my command line option,hello, to be echoed here as well 
uid=544(oradev) gid=500(dba) groups=500(dba)

our command line option, $1=hello, is working fine before switching the user, but for some reason it is not showing up after switching user.
I would be really happy if any one has any ideas on how to get this worked.
 


MALIBAL Linux Laptops

Linux Laptops Custom Built for You
MALIBAL is an innovative computer manufacturer that produces high-performance, custom laptops for Linux.

For more info, visit: https://www.malibal.com

Members online


Top