How to call shell script from another shell script from another user?
Can you please share the sample code?
I have two scripts:
showdate.sh:
#! /bin/bash
echo "Date is : `date`"
and mainscript.sh:
#! /bin/bash
su - nmsadm
echo " You are logged in as `whoami`"
echo "`./showdate.sh`"
When I am executing mainscript I want to switch to other user and run showdate script.
Here is the output
#./mainscript.sh
You have new mail.
-bash-3.2$
It switches to nmsadm user but does not execute show script.