Shell Script Experience Shell Scripting Important Syntax for loop Switch Case


Shell script kicstart automation issue
1)what we are tyring on the command line same thing we need to add the script - don't change single character
2)redirection > or >> we need to carefull judge.
3)fist part - Network configuration

Writing Shell script
1)Before executing we need to test it.
Specially if we are going to execute on the production we need to be very cautious.
The reason is when we are going to execute we will get lot of unrelated stuff from what we expected.
2)I.e From the output qstat -fx <job-id> | To get the runtime folder and pbs_spawn folder, I have to write the script exactly greb that particular folder rather than getting unwanted things. For this we have to test(inspected) with different input. I.e similar kind of problem I have faced in the creating outlook mail rules also. If I am not properly creating the mail rules, even without reading important mail it will move into rules folder.  “Truth is confirmed by inspection and delay; falsehood by haste and uncertainty” – Tacitus.
1)we need to place right mail into right rule. 

From the Python Scripting – How To Improve the Programming and Debugging Skill
1)We should have presence of mind.  we should know what we are doing.
2)when we write the program, every character is important Or else we will get the syntax error.
3)what we are getting the syntax error message read it and take steps depends on that.
4)Use the Syntax Highlighter IDE to easily the fix the problem.

Important  If Condition, For Loop While Loop
if Condition : Syntax
If [ condition ] ; then
elif [condition] ; then
{statement }
Note : Semicolon and then is important.

For Loop- Method -1
For ( ( c=1;c<=5;c++))
echo “ Welcome $c times “

Method 2
for c in 1 2 3 4 5
echo "welcome $c Times"
Method 3
for c in {1..5}
echo "welcome $c Times"

Read variable in shell script
read { variable name }

While Loop Statement
while [ $c -le 15 ]
echo "Welcome $c times"

Switch case Example
Case $check in
1) echo “redhat;;
2) echo “ubunut” ;;
*) echo “none”
Trigger the Back Ground Process to foreground
Process Id Vary from 0 to 65535

Shell Script How To Do The Addition With Variable
S=$((10+$i)) just like for loop for ((;;))

No comments:
Write comments