Saturday, February 9, 2013

What is Shell Script ? Why want to create Shell Script?

  • A shell script is a text file with Unix commands in it.
  • Shell scripts usually begin with a #! and a shell name (complete path-name of shell).
  • Path-name of shell be found using the which command.
  • The shell name is the shell that will execute this script.
  • If no shell is specified in the script file, the default is chosen to be the currently executing shell.

 E.g:
#!/bin/bash
 echo “Hello World”;
 exit 0;

Here
       #!/bin/bash    -  shell name , the program will execute this environment 


Why want to write shell script?

To avoid repetition:

  • If you do a sequence of steps with standard Unix commands over and over, why not do it all with just one command?
  • Or in other words, store all these commands in a file and execute them one by one. 

To automate difficult tasks:

 

Many commands have subtle and difficult options that you don’t want to figure out or remember every time .

To run the script:
$ chmod u+x myscript #set executable permission
$ ./myscript #Each line of the script is processed in order
       

ts


Why write shell scripts

Why write shell scripts ?

  



No comments:

Post a Comment

Price List Query for Item

 SELECT qph.list_header_id,        qph.name,        qph.description,        qphh.start_date_active,        qphh.currency_code,        q...