MilesWeb Hosting Forum

Please login or register.

Login with username, password and session length



SMF - Just Installed!

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - saurabhj

Pages: 1 [2]
How To's / How to write Shell Script ?
« on: July 17, 2015, 06:28:18 PM »
Following steps are required to write shell script:

(1) Use any editor like vi or mcedit to write shell script.

(2) After writing shell script set execute permission for your script as follows
chmod permission your-script-name

$ chmod +x your-script-name
$ chmod 755 your-script-name
Note: This will set read write execute(7) permission for owner, for group and other permission is read and execute only(5).

(3) Execute your script as
$ bash your-script-name
$ sh your-script-name
$ ./your-script-name

$ bash bar
$ sh bar
$ ./bar

Note: In the last syntax ./ means current directory, But only . (dot) means execute given command file in current shell without starting the new copy of shell, The syntax for . (dot) command is as follows

. command-name

$ . foo

Now you are ready to write first shell script that will print "Milesweb Hosting Services" on screen. See the common vi command list , if you are new to vi.
$ vi first
# My first shell script
echo "Milesweb Hosting Services"

After saving the above script, you can run the script as follows:
$ ./first

This will not run script since we have not set execute permission for our script first; to do this type command
$ chmod 755 first
$ ./first

First screen will be clear, then following output will appear on screen.
Output :
Milesweb Hosting Services

How To's / What are diffrent types of shell available in linux ?
« on: July 17, 2015, 05:36:09 PM »
Different types of shell

A number of different shells have been developed for Unix-Like Operating System; the most popular are described here.

[1]  Bourne Shell(sh):-
        Original Shell of Unix.
        Written by Stephen Bourne at Bell Labs in 1974.
        Lacked interactivity provided by most modern shells.

[2]  C Shell(csh) :-
        provides a C-like language to write shell scripts

[3]  Korn Shell :-
        created by David korn
        Has features of C and Bourne shell along with some additional features.

[4]  TC shell (tcsh) :-
        Default shell of FreeBSD and its descendants.
        Available in the public domain.

[5]  Bourne-again shell (BASH) :-
        Default shell of Linux Operating System.
        Developed by GNU project
        It is based on Bourne shell and has features of Bourne and C shell as well

How to check Shell's available in your system ?
Quote   :   cat /etc/shells

To find your current shell type following command
Quote   :   echo $SHELL

How To's / What is Shell Script ?
« on: July 17, 2015, 05:31:09 PM »
Normally Shells are interactive. It means shell accept command from you (via keyboard) and execute them. But if you use command one by one (sequence of 'n' number of commands) , then you can store this sequence of command to text file and tell the shell to execute this text file instead of entering the commands.

This is know as Shell script.

Shell script defined as:
"Shell Script is series of command written in plain text file. Shell script is just like batch file in MS-DOS but have more power than the MS-DOS batch file."

Pages: 1 [2]