1752793 Members
5870 Online
108789 Solutions
New Discussion юеВ

learn scripting

 
SOLVED
Go to solution
Shah Gaurang B.
Frequent Advisor

learn scripting

Hi Friends,

I have to start scripting can you all experts guide me how to start and which books or documents will give me good guidance and help me to understand the concepts of scripting.

thanks to all in advance
11 REPLIES 11
James R. Ferguson
Acclaimed Contributor
Solution

Re: learn scripting

Hi Shah:

There are many, many good books. However, a Google search for "shell scripting" will return a multitude of free tutorials.

A quick-read (free) book can be found here on HP's web:

http://www.docs.hp.com/en/B2355-90046/B2355-90046.pdf

This guide will give you a good, quick overview. Concentrate on the Posix/Korn shell since the Posix one is the standard HP shell. Too, out of this line (Posix/Korn) the 'bash' shell has evolved --- a standard in Linux.

An excellent site for scripts can be found here:

http://www.shelldorado.com/

This site has some good tutorials, guides to sound practices, and a fair number of scripts that allow you to see how someone else attacked a problem.

Regards!

...JRF...

inventsekar_1
Respected Contributor

Re: learn scripting

Hi Shah,

In my view Better idea is to learn from others scripts.

find / -name *.sh

this will give you lot of scripts. view any thing u like. refer books or google after seeing the scripts.

All the best!!!
Keep learning!!!
Sekar
Be Tomorrow, Today.
James R. Ferguson
Acclaimed Contributor

Re: learn scripting

Hi (again):

There are two things wrong with:

# find / -name *.sh

The first is that should the directory contain more than one file ending in '.sh', then the 'find' command will *fail* with:

find: missing conjunction

To see why, do:

# echo *.sh

...and then consider that the entire evaluation is passed as an argument to 'find'.

The proper form would be:

find / -name "*.sh"

...which passes the argument intact to 'find' for its evaluation.

The second thing wrong with:

# find / -name *.sh

is the assumption that shell scripts must end with the '.sh' extension. They do not, and this is only a matter of choice. You will miss many, many good scripts making this assumption.

Regards!

...JRF...

Marvin Strong
Honored Contributor

Re: learn scripting

Another problem with reading someones script is unfortunatley not all admins comment their scripts well. So you learn some syntax or structure, but have no idea how or why it does what it does.

IMO reading others scripts is good, but first you have to understand what your reading thus have some basic shell scripting knowledge.

Tutorial sites, and books are great for getting this basic and even sometimes advanced knowledge.

rmueller58
Valued Contributor

Re: learn scripting

There are two books I recommend as MUST have references..
Kochan and Wood - Shell Programming is a must


http://www.amazon.com/gp/product/0672324903/sr=8-2/qid=1154358108/ref=pd_bbs_2/104-8946161-4270352?ie=UTF8

A. Clay Stephenson
Acclaimed Contributor

Re: learn scripting

I will also make the suggestion that you learn only a little shell scripting and instead concentrate on learning Perl. If you know Perl, you get all the power of the shell, awk, sed, and grep rolled into one tool. If I were starting over, that would be my approach.
If it ain't broke, I can fix that.
Jonathan Fife
Honored Contributor

Re: learn scripting

If you have any sort of coding background, shell scripting will be cake. As for tools to get you started, it really depends on how you learn.

I'd suggest looking at online tutorials. They'll walk you through simple examples and get your feet wet. The ksh man page is also a very good reference, and being familiar with the different variables and builtins is helpful once you get going.

Once you're done with the basics, then I'd go hacking into scripts other admins have written. Documentation or no, if you have the fundamentals down (and google available), then you should be able to reverse-engineer pretty much any script out there.

If you feel the need for dead tree books:
Learning the Korn Shell
Classic Shell Scripting
both published by O'Reilly.
Decay is inherent in all compounded things. Strive on with diligence
Steven E. Protter
Exalted Contributor

Re: learn scripting

Shalom,

There are lots of good questions here on how to script this and that. Just spend 10 minutes a day reading the questions.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
inventsekar_1
Respected Contributor

Re: learn scripting

JRF,
thanks again for making me (and lot of others) clear...

/* is the assumption that shell scripts must end with the '.sh' extension. They do not, and this is only a matter of choice. You will miss many, many good scripts making this assumption. */

when he learn UNIX OS Structure well, they will come to know those scripts.
for the first time, they can try that one.. that is why i used that "find".

Be Tomorrow, Today.