LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Run script from within a script and then continue? (https://www.linuxquestions.org/questions/linux-newbie-8/run-script-from-within-a-script-and-then-continue-4175497429/)

postcd 03-07-2014 04:37 PM

Run script from within a script and then continue?
 
Code:

echo "Run vzmigrate (m) or run vzdump (d) now? or any other key to continue."
read vmsbckp
if [ "$vmsbckp" == "m" ];then
./root/vzmigrate
fi
if [ "$bmsbackup" == "d" ];then
./root/vmsbackup
ls -l /home/vmsbackup
fi
echo "That is all, nothing more to be done in backup process."

when i selected "d"

it just skipped and exitted the script. Can i modiffy anyhow script so it start another script and then when this finish it automatically continue my firs initial script?

suicidaleggroll 03-07-2014 04:40 PM

Are you sure it skipped it? Chances are the script you were calling just didn't do anything (errored out, etc). Try running with "set -x".

Firerat 03-07-2014 05:16 PM

try either of these forms

Code:

if [ <condition> ]; then
    # note space between ; and then
    <code>
fi


Code:

if [ <condition> ]
then
    <code>
fi


Edit, you might want to consider case

Code:

read vmsbckp
case $vmsbckp in
    M|m) <code>
      ;;
    D|d) <code>
      ;;
      *) echo "wrong answer!"
      ;;
esac



All times are GMT -5. The time now is 05:26 AM.