Advertisement

09.12.2008 at 01:41AM PDT, ID: 23725681 | Points: 500
[x]
Attachment Details

Bash Script elif error. Syntax error near unexpected token 'elif' bash scripting

Asked by harps21k in Bourne-Again Shell (bash), Linux Programming, Scripting Languages

Tags:

HI,

Im having problems with my bash script that I am using for automated zenwork imaging. I always get a elif error on line 23. Error message is Syntax error near unexpected token 'elif' bash scripting line 23. Can anyone please help.
Script is shown below.

mount dev/sda2 -t ext2 mnt/harddisk
Option=""
while [ "$Option" != "4" ]
do
echo ""
echo "THH Data Migration - Zen Imaging"
echo "--------------------------------"
echo "1            View ZEN Partition Info"
echo "                                "
echo "2             Take Backup Image of PC"
echo "                                "
echo "3             Restore WinXPBase      "
echo "                                "
echo "4        Back to Bash Prompt    "
echo "                                "
echo "5             Exit & Reboot          "
echo "--------------------------------"
echo "Please Enter Your Choice:"
read Option;
if [ "$Option" = "1" ]; then
      img dump geo
      echo "View Partition Info";
elif [ "$Option" = "2" ]; then
      ImageNAME=""
      while [ "$ImageNAME" = "" ]
      do
            echo "Please Enter Asset Number For Backup of Image: ";
            read ImageNAME;
      done
      PartNo=""
      while [ "$PartNo" = "" ]
      do
            echo "Please Enter Windows Partition No from Step 1: ";
            read PartNo;
      done
            if [ "$PartNo" = "1" ]; then
            img ml mnt/harddisk/PCBackups/$ImageNAME.zmg x2 x3 x4 x5 x6 x7 x8
            elif [ "$PartNo" = "4" ]; then
            img ml mnt/harddisk/PCBackups/$ImageNAME.zmg x1 x2 x3 x5 x6 x7 x8
            fi
elif [ "$Option" = "3" ]; then
      PartNo=""
      while [ "$PartNo" = "" ]
      do
            echo "Please Enter Windows Partition No from Step 1: ";
            read PartNo;
      done
      if [ "$PartNo" = "1" ]; then
      img rl mnt/harddisk/newwinxpbase.zmg a1:p1
      if hwinfo --bios | grep -i "D510"; then img rl mnt/harddisk/Driversets/d510.zmg a1:p1
      elif hwinfo --bios | grep -i "D530"; then img rl mnt/harddisk/Driversets/d530.zmg a1:p1
      elif hwinfo --bios | grep -i "D5000"; then img rl mnt/harddisk/Driversets/d530.zmg a1:p1
      elif hwinfo --bios | grep -i "D5100"; then img rl mnt/harddisk/Driversets/d530.zmg a1:p1
      elif hwinfo --bios | grep -i "dc7100"; then img rl mnt/harddisk/Driversets/dc7100.zmg a1:p1
      elif hwinfo --bios | grep -i "dc7600"; then img rl mnt/harddisk/Driversets/dc7600.zmg a1:p1
      elif hwinfo --bios | grep -i "dc7700"; then img rl mnt/harddisk/Driversets/dc7700.zmg a1:p1
      elif hwinfo --bios | grep -i "dc7800 "; then img rl mnt/harddisk/Driversets/dc7800.zmg a1:p1
      elif hwinfo --bios | grep -i "Ultra"; then img rl mnt/harddisk/Driversets/dc7800usd.zmg a1:p1
      fi
      if hwinfo --cpu | grep -i "Units/processor: 2"; then img rl mnt/harddisk/Driversets/multiCPU.zmg a1:p1;
      fi
      elif [ "$PartNo" = "4" ]; then
      img rl mnt/harddisk/newwinxpbase.zmg a1:p4
      if hwinfo --bios | grep -i "D510"; then img rl mnt/harddisk/Driversets/d510.zmg a1:p4
      elif hwinfo --bios | grep -i "D530"; then img rl mnt/harddisk/Driversets/d530.zmg a1:p4
      elif hwinfo --bios | grep -i "D5000"; then img rl mnt/harddisk/Driversets/d530.zmg a1:p4
      elif hwinfo --bios | grep -i "D5100"; then img rl mnt/harddisk/Driversets/d530.zmg a1:p4
      elif hwinfo --bios | grep -i "dc7100"; then img rl mnt/harddisk/Driversets/dc7100.zmg a1:p4
      elif hwinfo --bios | grep -i "dc7600"; then img rl mnt/harddisk/Driversets/dc7600.zmg a1:p4
      elif hwinfo --bios | grep -i "dc7700"; then img rl mnt/harddisk/Driversets/dc7700.zmg a1:p4
      elif hwinfo --bios | grep -i "dc7800 "; then img rl mnt/harddisk/Driversets/dc7800.zmg a1:p4
      elif hwinfo --bios | grep -i "Ultra"; then img rl mnt/harddisk/Driversets/dc7800usd.zmg a1:p4
      fi
      if hwinfo --cpu | grep -i "Units/processor: 2"; then img rl mnt/harddisk/Driversets/multiCPU.zmg a1:p4;
      fi
      else
      echo "Invalid Partition Number, Please contact Harps or Bal: ";
      fi
elif [ "$Option" = "5" ]; then
      reboot -f
fi
doneStart Free Trial
 
Loading Advertisement...
 
[+][-]09.12.2008 at 01:50AM PDT, ID: 22458040

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.12.2008 at 01:55AM PDT, ID: 22458052

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.12.2008 at 02:00AM PDT, ID: 22458068

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.12.2008 at 03:44AM PDT, ID: 22458454

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628