New to Linux - Network engineer wants to learn Scripting
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.
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:
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 ?
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. ;-)
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. ;}
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.
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.
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
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.
Thanks for putting a smile on my face.
+1 to the funny ... and also agree about the syntax :)
Glad to entertain ;}
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.
|All times are GMT -5. The time now is 10:24 PM.|