dimanche 1 juillet 2018

Bash Script is not working

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.

Aucun commentaire:

Enregistrer un commentaire