0

so I would like to know how to create a script the performs three basic commands.

sudo su - Admin
     cd ~/AMP
     ./ampinstmgr -a

This is what I got, I have also given it 777 perms.

#! /bin/sh
# /etc/init.d/run.sh
#

# Some things that run always
touch /var/lock/run

# Carry out specific functions when asked to by the system
case "$1" in
  start)
     sudo su - Admin
     cd ~/AMP
     ./ampinstmgr -a
    ;;
  stop)

    ;;
  *)
    exit 1
    ;;
esac

exit 0
0

Rather than 3 commands

sudo su - Admin
 cd ~/AMP
 ./ampinstmgr -a

Simply use sudo to execute the command as user Admin directly (and don't rely on ~ expansion but use absolute paths in sudo commands):

sudo -u Admin /home/Admin/AMP/ampinstmgr -a
  • So is there anything that I have to do to make this script run in the init.d folder? I changed it to sudo -u Admin /home/Admin/AMP/ampinstmgr -a –  TheSourceCode Jun 22 '17 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.