Need to know before starting scripting

Scripts •Contain a series of commands •An interpreter executes commands in the script •Anything you can type at the command line, you can put in a script •Great for automating tasks Basic Syntax •#! /bin/bash # Commands •Shebang / HashBang • #! /bin/bash • Informs Linux which command line interpreter to use for the script; … Continue reading Need to know before starting scripting

Few sample scripts

#!/bin/more ============================== SCRIPT NAME: arrayex.sh ============================== #!/bin/bash # simple array list and loop for display SERVERLIST=("websrv01" "websrv02" "websrv03" "websrv04") COUNT=0 for INDEX in ${SERVERLIST[@]}; do echo "Processing Server: ${SERVERLIST[COUNT]}" COUNT="`expr $COUNT + 1`" done ============================== ============================== SCRIPT NAME: checkargs2.sh ============================== #!/bin/bash : ${3?"USAGE: $1 ARGUMENT $2 ARGUMENT $3 ARGUMENT"} echo "I got all three!" ============================== … Continue reading Few sample scripts

screen command

Install the screen package yum install screen -y apt-get install screen -y mohammedrafi@NOC-RAFI:~$ tty /dev/pts/0 screen -S session-name will create a new session on terminal with that name mohammedrafi@NOC-RAFI:~$ screen -S session1 Open another terminal and search with command screen -ls to list sessions's mohammedrafi@NOC-RAFI:~$ tty /dev/pts/5 mohammedrafi@NOC-RAFI:~$ screen -ls There is a screen on: … Continue reading screen command