LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-07-2014, 04:37 PM   #1
postcd
Member
 
Registered: Oct 2013
Posts: 527

Rep: Reputation: Disabled
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?
 
Old 03-07-2014, 04:40 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
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".
 
Old 03-07-2014, 05:16 PM   #3
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
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

Last edited by Firerat; 03-07-2014 at 05:22 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] net snmp pass persist script, can not run a bash script!! Linux Chips Linux - General 4 12-23-2012 01:50 PM
MySQL Updates With Null When Perl Script Run From Shell Script ThisGuyIKnow Programming 6 08-12-2008 09:56 AM
Will script continue to run even after closing putty for remote access anjanesh Linux - Newbie 11 08-07-2006 03:05 AM
on Network Up Script run? On Battery power run script? v2-ncl Linux - General 0 12-08-2003 09:34 AM
Continue running a script after logging out? AlvinK Linux - Newbie 0 08-28-2003 06:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration