Highlighted
Respected Contributor.
Respected Contributor.
197 views

(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

Labels (1)
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.