(SM) Support Tip: How to create shell script to execute the scenario to SM.

How to create a CIT service in linux and write shell script to execute the scenario to SM.

 For bash script , here is reference for loop:

 This type of for loop is characterized by counting. The range is specified by a beginning (#1) and ending number (#5). The for loop executes a sequence of commands for each member in a list of items. A representative example in BASH is as follows to display welcome message 5 times with for loop:

#!/bin/bash

for i in 1 2 3 4 5

do

echo "Welcome $i times"

done

#!/bin/bash for i in 1 2 3 4 5 do echo "Welcome $i times" done

Sometimes you may need to set a step value (allowing one to count by two’s or to count backwards for instance). Latest bash version 3.0 has inbuilt support for setting up ranges:

#!/bin/bash

for i in {1..5}

do

echo "Welcome $i times"

done

#!/bin/bash for i in {1..5} do echo "Welcome $i times" done

Bash v4.0 has inbuilt support for setting up a step value using {START..END..INCREMENT} syntax:

#!/bin/bash

echo "Bash version ${BASH_VERSION}..."

for i in {0..10..2}

do

echo "Welcome $i times"

done

#!/bin/bash echo "Bash version ${BASH_VERSION}..." for i in {0..10..2} do echo "Welcome $i times" done

Sample outputs:

Bash version 4.0.33(0)-release...

Welcome 0 times

Welcome 2 times

Welcome 4 times

Welcome 6 times

Welcome 8 times

Welcome 10 times

 

I prefer this way.

#!/bin/bash

echo "starting shell";

#copy the your PATH and LD_LIBRARY_PATH from his shell script

PATH=$PATH:xxxxx/ConnectIt/bin

export LD_LIBRARY_PATH=xxxxx

for (( c=1; c<=10; c ))

do 

conitsvc -svc -log:cit$c.log test.scn

done

#end script

You can also create corn to execute the shell script like below:

test for ***.sh

*/5 * * * *  /opt/HP/ServiceManager9.33/ConnectIt/scenario/**_scenario/**_monitor/test/test.sh  >> /opt/HPE/test.log

 So the shell script will be executed every 5 min.

 

Thanks

Tags: