When i am writing the script like this
#!/bin/sh pidof MX-CM48 | xargs kill if [ -f /home/root/MX-CM48NEW ]; then mv /home/root/MX-CM48NEW /home/root/MX-CM48 chmod 777 /home/root/MX-CM48 fi cd /home/root ./MX-CM48 &
the script is working.
but when i am trying to write it like this:
#!/bin/sh NEW_FILE="/home/root/MX-CM48NEW" OLD_FILE="/home/root/MX-CM48" PATH="/home/root" APP_NAME="MX-CM48" pidof $APP_NAME | xargs kill if [ -f $NEW_FILE ]; then mv $NEW_FILE $OLD_FILE chmod 777 $OLD_FILE fi cd $PATH ./$APP_NAME &
the pidof and the if are not working.
Advertisement
Answer
Unless you copied all commands to /home/root
, it is pretty clear what is wrong.
PATH="/home/root"
should (probably) be:
PATH="$PATH:/home/root"
or use full path-names, like in:
/usr/bin/pidof $APP_NAME | /usr/bin/xargs /bin/kill