Batch Programming (Dos Scripting) VS Shell Scripting

0 comments

When I started my career in IT field. I have landed into windows world, as i know that no companies give a chance to fresher to work on production Linux servers.. Its a good experience to work on DOS scripts(aka Batch programming). There are so many similarities/differences/advantages/disadvantages between Batch programming and Shell scripting. Lets see what they are.

Similarities


Sl.No Batch programming Shell script
1 Batch execution of commands in a batch file Batch execution of command in shell scripts
2 Can read inputs from users Can read inputs from users
3 Has control structures such as for, if, while, switch for better automating/scripting Has control structures such as for, if, while, switch for better automating/scripting
4 Supports advanced features such as Functions and Arrays Supports advanced features such as Functions and Arrays
5 Supports regular expressions(using findstr) Supports regular expressions
6 Can include other programming codes such as perl(ie.. in middle of dos script we can include some other programming language code for effective scripting) Can include other programming codes such as Perl, AWK, SED etc.
 

Differences

Sl.No Batch programming Shell script
1 Lack of richness of tools/commands Have good number of tools(as of my knowledge there are more than 75000 commands)
2 Supports only one vender(ie windows) Supports for number of venders such as Sun/apple/IBM AIX/HP-UX etc.
3 No other variants for DOS In Shall there are no of variants such as bash, ksh, csh, zsh etc..
4 Low capabilities of integrating with other programming code in batch scripting Good capabilities of integrating other programming code in shell script
5 Cannot handle complex regular expressions Can handle complex regular expressions.
6 A batch file should always end with .bat There is no such concept like file extension, but a shell script file permission should be set to executable.
7 To execute a batch program just enter the file name at CLI To execute a shell script, here are the ways to execute it
1)chmod +x shellscript.sh;./shellscript.sh
2)sh shellscript.sh



Good article on how to convert your Batch program to a Shell script.
http://tldp.org/LDP/abs/html/dosbatch.html

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Archive

    Translate this page

     

    The Linux Juggernaut | Copyright 2006-2009 Surendra Kumar Anne | Surendra's Home Page | Give us feedback how we are doing, Click here