Welcome, Guest
Username Password: Remember me

shell script to run x times
(1 viewing) (1) Guest
Shell Script
  • Page:
  • 1

TOPIC: shell script to run x times

shell script to run x times 2 years, 2 months ago #158

  • rajeshkumar
  • OFFLINE
  • Moderator
  • I love software configuration management
  • Posts: 370
  • Points: 44590
  • Karma: 4
  • Honor Medal 2009
Problem:

First i need to cd to this directory $SWDIR/util
Second i need to run the following either 4 times or 20 times

./swadm add_process 1 BG Y

how can i put this in a script
Regards,
Rajesh Kumar
Build and Release Engineer
My Blog: community.scmgalaxy.com/pg/profile/rajeshkumar

Re:shell script to run x times 2 years, 2 months ago #159

  • rajeshkumar
  • OFFLINE
  • Moderator
  • I love software configuration management
  • Posts: 370
  • Points: 44590
  • Karma: 4
  • Honor Medal 2009
Solution

# Change directory
cd $SWDIR/util
 
# Set the variable n, which should store the number of iterations,
# either to 4 when condition "bla_bla" or else to 20
if bla_bla then
n=4
else
n=20
fi
 
# loop n times and do something in that loop
# (initialize the variable i with 1, then loop as long as i is
# smaller than or equal the variable n. increase i by 1 on
# every looping)
for (( i=1; i<=$n; i++ ))
do
./swadm add_process 1 BG Y
done
Regards,
Rajesh Kumar
Build and Release Engineer
My Blog: community.scmgalaxy.com/pg/profile/rajeshkumar
  • Page:
  • 1
Time to create page: 0.86 seconds

     
    
Home Forum