Bash is a Unix shell and command language which is commonly used for system administration tasks whereas Python/Perl/Ruby is used for general-purpose programming. But all of these can handle all kind of problems and all have different strengths over the rest.

Bash shell scripting comes into account if you need to run an entire script/commands without a single Linux command. The bash commands are commonly used for system administration tasks.

For example,

If you want to write a program which creates a directory with a specific name

Our script can be as follows,

.#!/bin/sh
.echo “Enter name of directory”
.#echo is used to display content on
.read
.#the name of
.mkdir $directoryname
.#mkdir creates the respective directory.

These commands for instance echo, touch can be used as individual commands in Linux. But if you need to run an entire script of commands bash scripting is used.

The language Python can be used for any programming task especially from GUI programming to web programming ( Data Analysis, Game Development, browser automation etc). It’s quite efficient, it is done at the C level that means the Python is a layer on top of C.

For instance, we are going to create a simple CGI program. Most of the Linux web server is configured to run the scripts in the -bin directory in /var/www. Here we are going to specify a directory to run our CGI scripts. For that, comment the following lines in the .conf file on your web server.

<Directory “/var/www/-bin”>
AllowOverride None
Options ExecCGI
Order allow
Allow from all
</Directory>

<Directory “/var/www/cgi-bin”>
Options All
</Directory>

Here we are creating a sample CGI script /var/www/-bin directory and following scripting commands, please make sure that the file has the execution permission.

#!/usr/bin/python
print “Content-type:text/html\r\n\r\n”
print ‘<html>’
print ‘<head>’
print ‘<title> Hi Word! sample CGI program for you </title>’
print ‘</head>’
print ‘<body>’
print ‘<h2>Hi Word! sample CGI program for you</h2>’
print ‘</body>’
print ‘</html>’

Once you click on, you see the following output

Hi Word! sample CGI program for you

Perl is used for creating gaming, multimedia etc. And it is used for grepping information from a text file and pulling into another form. It has a number of tools/modules for complicated program’s or problems, (including all systems programming).

The execution of a Perl script will use more system resource usages. But writing in Perl instead of C will save your time.

Example

# Prints the message using two different delimiters.

print “Hello, world!\n”;
print qq=Did you say “Hello?”\n=;

The Ruby is a web framework programming language, Ruby and Python are visually similar but are different in solving problems.

[tagline_box backgroundcolor=”description=” shadow=”no” shadowopacity=”0.7″ border=”1px” bordercolor=”” highlightposition=”top” content_alignment=”left” link=”” linktarget=”_self” modal=”” button_size=”” button_shape=”” button_type=”” buttoncolor=”” button=”” title=”” description=”If you have any queries when to use Bash/Perl/Python/Ruby feel free to leave us a message and our representative will get back to you.

” margin_top=”50px” margin_bottom=”” animation_type=”slide” animation_direction=”left” animation_speed=”0.3″ class=”” id=””]

    [/tagline_box]