Operating System - HP-UX
1752587 Members
3942 Online
108788 Solutions
New Discussion

Re: How to loop 4 different scripts in one script step by step

 
Vishal_1980
Regular Advisor

How to loop 4 different scripts in one script step by step

Hello expert ,

 

I have made 4 scripts & i want to run those scipts in a single hit ,which will give me the succelssfull complition message & will ask me just to hit the no like hit 1 to execute script 1 etc ..a switch though ,therefore i am not that much aware or good in scripting.here i am attaching the scripts for your ready reference according to order .request yo to please help me out.

PFA scripts ...

 

 

P.S. This thread has been moved from HP-UX > System Administration to HP-UX > languages. - Hp Forum Moderator

6 REPLIES 6
Dennis Handly
Acclaimed Contributor

Re: How to loop 4 different scripts in one script step by step

If you want to execute the 4 other scripts, you can simply have a command line option to invoke one of them.

 

If you want a loop with a menu, you can use the select statement to prompt a list of choices.

You can then read the result and then execute one of the scripts.

 select identifier [in word...]; do list done

 

select result in script1 script2 script3 script4; do
   if [ "$result" = "" ]; then
      echo "Bad input: $REPLY"
   else
      echo "$result: $REPLY"
   fi
done

 

Vishal_1980
Regular Advisor

Re: How to loop 4 different scripts in one script step by step

Thanks Dennis,

 

However will you please just let you know for 1 or 2 scripts so that i can perform the rest of the scripts.

There are 12 scripts though that i made.

Please help me out.

 

Thanks & regards,

Vishal

Vishal_1980
Regular Advisor

Re: How to loop 4 different scripts in one script step by step

Can you just show you one example ..so that i can start with somewhere ....

 

Thanks,

Vishal

Dennis Handly
Acclaimed Contributor

Re: How to loop 4 different scripts in one script step by step

>Can you just show you one example?

 

select result in lmrk_base_dirs script2 script3 script4 exit; do
   if [ "$result" = "" ]; then
      echo "Bad input: $REPLY"
   else
      echo "$result: $REPLY"
      case $result in
      lmrk_base_dirs) lmrk_base_dirs.sh
          ;;
      script2) execute_script_2
          ;;
      script3) execute_script_3
          ;;
      script4) execute_script_4
          ;;
      exit)    exit
          ;;
      *)       echo "Mismatch with select and case" 1>&2
               exit 1
               ;;
      esac
   fi
done

Vishal_1980
Regular Advisor

Re: How to loop 4 different scripts in one script step by step

Hello Dennis,

Thanks a ton for thsi help .However, do i need to speecify the path of the script location.

I am really new to scripting ,please guide me to resolve this.

 

Thanks,

Vishal

Dennis Handly
Acclaimed Contributor

Re: How to loop 4 different scripts in one script step by step

>do I need to specify the path of the script location?

 

If these scripts are in your $PATH, then no.

Otherwise you can use absolute paths.

Or you can augment $PATH in your script:

PATH=new-path:$PATH