need a help for shell script
Hi,
Hereby i do attached the script which should be run only by root, yet root login was disabled in server. So within the script i need to switch to root account and the script should be executed. Please help me to resolve this. I am trying to run the script but the script fails in first step after switching to root account.
#!/bin/bash
su -
echo "password"
usr1=gprsuser
usr2=prov
pass1=gp123#
pass2=pr123#
#group=groupname
/bin/mkdir -p /102/gprsuser
/bin/mkdir -p /102/prov/PROV_LIS_RESP_DIR
/bin/touch /script_log
#/usr/sbin/groupadd groupname -g 501
/usr/sbin/useradd -d /102/gprsuser -m -s /sbin/nologin -g 500 -u 520 $usr1
passwd $usr1 << EOF
$pass1
$pass1
EOF
#cp /etc/skel/. /102/$usr1
#chown -R $usr1:$group /102/$usr1
chmod -R 770 /102/gprsuser
grep gp /etc/passwd
if [ $? -eq 0 ]
then
echo "gprsuser created sucessfully on `date`" >> /script_log
else
echo "gprsuser failed to create on `date`" >> /script_log
fi
|