New to Linux - Network engineer wants to learn Scripting
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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:
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. ;}
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.
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.