LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-01-2012, 01:52 PM   #1
GBIEC
LQ Newbie
 
Registered: Oct 2011
Location: London
Distribution: Ubuntu, Red Hat
Posts: 6

Rep: Reputation: Disabled
Smile New to Linux - Network engineer wants to learn Scripting


Hi Guys,

I am new to Linux however know the basics. Recently i have installed VM Ware to access Linux environment.

I am a CISCO based network engineer, but got a massive interest in Linux and scripting every since i started my career in 2005.

If you really ask me at this point i don't even know what is scripting but as long as i know it automates processes.

I don't have any programming background at all but i am willing to learn. Some of my friends suggested me to learn PERL scripting as well.

I would really appreciate if someone can share their expertise on this matter and help me to choose a scripting language and what all can i do with scripting.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 03-01-2012, 02:00 PM   #2
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,689

Rep: Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987
Well the usual story is to select the right tool for the job. Perl, Python or Ruby may be great if you require powerful control over the task but would be a waste
on something as simple as changing a single line in a file, hence you may use sed, awk or even bash.

Generally I find the best way to get into scripting is to find a task you require to be done and solve it. I also find I learn better when the task means
something to me and so I know the expected outcomes well.

Here are some pages to help you depending on what you need:

http://tldp.org/LDP/abs/html/
http://mywiki.wooledge.org/TitleIndex
http://www.gnu.org/software/gawk/man...ode/index.html
http://www.grymoire.com/Unix/Sed.html
http://docs.python.org/
http://www.perl.org/books/beginning-perl/
http://www.ruby-lang.org/en/documentation/
 
3 members found this post helpful.
Old 03-01-2012, 02:07 PM   #3
GBIEC
LQ Newbie
 
Registered: Oct 2011
Location: London
Distribution: Ubuntu, Red Hat
Posts: 6

Original Poster
Rep: Reputation: Disabled
Appreciated your quick response.

So do you mean there is not 1 scripting language to be learned and i can achieve whatever i try to ?

Cheers
 
Old 03-01-2012, 02:54 PM   #4
wpeckham
Member
 
Registered: Apr 2010
Location: USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix
Posts: 832

Rep: Reputation: 181Reputation: 181
Oh my, just ... just ... Oh my!

First, every shell that has an interactive mode (the VAST majority) has a built-in scripting language interpreter.
That means there are scripting languages SH -posix, ASH, BASH, CSH, DASH, KSH, ZSH, and very likely a dozen others that are SHELL features.
Most of the features of the major ones are somewhat similar, so that ksh works like bash (for example) until you get into unique features.
If you want to learn shell, I recommend bash.
---
Second are the script languages that are portable and non-shell based, such as the three Ps (PERL, PYTHON, and PHP), Ruby, REXX, even several variants of BASIC! There are also general tools in the toolset that allow for a significant level of scripting power such as SED and AWK. There are even metal-language translators for those who take their scripting to the third remove (I want to HATE those guys).
---
Decide what environments you want to script in, and what kinds of jobs you will do the most, and from that we may be able to advise you on what script languages are most likely to be globally available for your use. From those, you can pick the one that sounds most useful to you and start to "play with things a little".
----------
Extra points if you recognize the quote. ;-)
 
Old 03-01-2012, 03:07 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
And to some extent the distro you choose will have an impact on the scripting
language you'll want to use, too. While it's easy enough to pull e.g. perl
modules in from CPAN, and I'd be happy to do that on a) MY workstation, or
b) on one or two servers if I need to accomplish certain tasks, I'd choose
python on RHEL because it's their default tool (yum et al are written in
python), and the python install is more complete by default.

Example: using satellite/spacewalk and extending it w/ scripts is more
easily done w/ python. The one lib you need as a dependency is already
installed. To do the same job in perl you'd end up pulling in about 20
cpan packages. And as said above - if I need to be able to run the script
on one or two boxes, that's fine. Looking at 200+ servers it becomes
quite unappealing. ;}


Cheers,
Tink
 
Old 03-01-2012, 03:40 PM   #6
archShade
Member
 
Registered: Mar 2006
Location: Delft NL
Distribution: Debian; Slackware; windows 7
Posts: 218

Rep: Reputation: 53
Quote:
Originally Posted by grail View Post
Generally I find the best way to get into scripting is to find a task you require to be done and solve it. I also find I learn better when the task means
something to me and so I know the expected outcomes well.
This is the key, when it comes to scripting (as with many things) the best way to learn is by doing. Also don't be afraid to google there is a decent chance that someone has already done what your trying to do so you may be able to find an example or something similar that you can take and change. The important thing is not to simply take an example and copy it, but read it and make sure you know what it does, try to work out why the original author decided to do what they did.

If you are just after automating general admin tasks you can't go wrong wrong with a borne shell compatible script. Pretty much all *nix systems (Linux, *BSD, OSX, etc..) and windows if you install cygwin will be able to run the script as long as they have all the tools you use.

I would also recommend learning to read man pages as these are very helpful but can be a bit opaque at times.

If you want to do somthing else (lots of text or numeric processing for example) then it is worth using a different tool, don't be afraid to ask which tool to use or for some help using it. The other thing to remember is that part of what makes a tool right for the job is that you are comfortable with it. For example if you become very proficient in Perl but want to do some heavy number crunching then you may get people telling you that the best tool is Octave or Python + Sci-Py, but you would probably get quicker and better results with Perl and PDL (Perl Data Language) (since you already know Perl).

Finally I can't stress enough that google is your friend, there are so many resources for scripting tutorials out on the Internet that very often you can find what you need by simply typing in "Bash script to $XYZ" (where $XYZ is what you want to do")

Best of luck and welcome to the world of doing a task once, and not having to repeat the mundanity of repeating yourself.
 
Old 03-01-2012, 04:09 PM   #7
jefro
Guru
 
Registered: Mar 2008
Posts: 12,078

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
Might even start with autoexpect. Most of the network stuff is not that complex so running autoexpect like you would normally makes a file that tends to work with expect command.

Last edited by jefro; 03-01-2012 at 04:10 PM.
 
Old 03-01-2012, 04:14 PM   #8
GBIEC
LQ Newbie
 
Registered: Oct 2011
Location: London
Distribution: Ubuntu, Red Hat
Posts: 6

Original Poster
Rep: Reputation: Disabled
Smile

Quote:
Originally Posted by wpeckham View Post
First, every shell that has an interactive mode (the VAST majority) has a built-in scripting language interpreter.
That means there are scripting languages SH -posix, ASH, BASH, CSH, DASH, KSH, ZSH, and very likely a dozen others that are SHELL features.
Most of the features of the major ones are somewhat similar, so that ksh works like bash (for example) until you get into unique features.
If you want to learn shell, I recommend bash.
---
Second are the script languages that are portable and non-shell based, such as the three Ps (PERL, PYTHON, and PHP), Ruby, REXX, even several variants of BASIC! There are also general tools in the toolset that allow for a significant level of scripting power such as SED and AWK. There are even metal-language translators for those who take their scripting to the third remove (I want to HATE those guys).
---
Decide what environments you want to script in, and what kinds of jobs you will do the most, and from that we may be able to advise you on what script languages are most likely to be globally available for your use. From those, you can pick the one that sounds most useful to you and start to "play with things a little".
----------
Extra points if you recognize the quote. ;-)
Mate i got no idea at all about scripting language that's why i posed this question. Adding to that i got no idea about your quote as well

What i need scripting is for Network Administration. Specially automating and streamline many common IOS configuration, monitoring, and problem-solving tasks in CISCO environment because that's what i do and i am good at. Following are the reasons for me to learn scripting.

1. Automate routine administration tasks iíve always performed manually
2. Instantly collect and modify device configurations and other data
3. Write Syslog scripts to document failures, monitor network health, collect statistics, and send alarm messages

I know there is scripting language called Tcl (Tool Command Language) which is supposed to be the best specially in CISCO environment. I dont know if you guys know about Tcl.

I hope it helps you to understand what i am looking to learn and why.

Cheers big ears
 
Old 03-01-2012, 06:51 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Quote:
I know there is scripting language called Tcl (Tool Command Language) which is supposed to be the best specially in CISCO environment. I dont know if you guys know about Tcl.

I hope it helps you to understand what i am looking to learn and why.

Yah, tcl is a venereal disease among scripting languages ;}


Just kidding - it's ubiquitous, portable, has the worlds fastest regex engine,
but a syntax that makes my toenails curl up and want to hide.



Cheers,
Tink
 
Old 03-01-2012, 10:32 PM   #10
evo2
Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,589

Rep: Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227
Quote:
Originally Posted by Tinkster View Post
Yah, tcl is a venereal disease among scripting languages ;}
Ohh, that made laugh!

Thanks for putting a smile on my face.

Evo2.
 
Old 03-02-2012, 02:07 AM   #11
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,689

Rep: Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987
+1 to the funny ... and also agree about the syntax
 
Old 03-02-2012, 03:23 PM   #12
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Glad to entertain ;}
 
Old 03-03-2012, 01:03 AM   #13
wpeckham
Member
 
Registered: Apr 2010
Location: USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix
Posts: 832

Rep: Reputation: 181Reputation: 181
The quote

A comment from Ming the Merciless to Clitus when asked if he was going to destroy the Earth.


I am unfamiliar with your environment. I work with many distributions of Linux, and ASTARO security devices. BASH (or KSH) and PERL are the tools I can find nearly everywhere. For something as specific and specialized as your CISCO environment you will need to research the scripting options, and make your choice from that subset.

It would make no sense for you to study Python (for example), if it is not going to be available to you.
A quick Google search seems to indicate that TCL is in fact the most common scripting tools that will serve. In that case you might be happy to learn that TCL interpreters are also available for all Linux distributions, Microsoft Windows, and even FreeDOS. You have a wealth of potential educational environments.

Last edited by wpeckham; 03-03-2012 at 01:08 AM.
 
  


Reply

Tags
linux, networking, scripting


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Which scripting language to learn for Linux Administration huracan10033 Programming 7 05-29-2011 10:15 AM
certification in linux for network engineer newbie4linux Linux - Certification 1 04-19-2009 04:55 PM
mechanical engineer tries to learn c wolve Programming 3 11-28-2004 11:43 PM
Network engineer, new to linux afriendlyface Linux - Networking 2 05-16-2004 03:47 PM


All times are GMT -5. The time now is 11:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration