LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Which scripting language to learn (https://www.linuxquestions.org/questions/linux-newbie-8/which-scripting-language-to-learn-686399/)

max_cherry 11-26-2008 12:11 PM

Which scripting language to learn
 
Say a person is working towards becoming a Redhat Systems Administrator/Engineer, and as required/advertised for many jobs in this role, needs the abiltiy to write scripts for administrative purposes.
Which language would be the best to learn (first) bash/perl/python .
I have seen advice that suggested it might be better to learn python rather than bash.
If the role were to cover web administration, then perl or php would also be required. Could learning perl cover both system and web administration purposes.

Many thanks for any replies. :scratch:
Max

jstephens84 11-26-2008 12:15 PM

Yes perl would be a good one to learn but I still feel bash would be a really great first scripting language to use. This is do to much of your system using bash scripts. IE startup and Shutdown scripts, and some in your /sbin are nothing more than bash scripts. So I am going to Say go bash first then look at what is needed in your area. In my area I hear bash / perl and or php.

arizonagroovejet 11-26-2008 01:26 PM

I've been increasingly responsible for administering Linux machines for a living for about six years. I don't know Python. Perl I've only start fiddling with in the last couple of days because I need a script to parse XML and bash is no good for that. I can handle PHP but have never used it for any sort of admin purpose, only for web content generation and then nothing to do with my job. What I use at work every single day is bash. The Linux machines I look after contain a bunch of useful scripts users can use to achieve various things from setting up Thunderbird for use with our email system with a few mouse clicks to resetting their KDE settings back to the defaults and they're all bash scripts. bash is what you have when you're at a command prompt so it really is the one to start with. You can do a lot of stuff simply by piping the output of one command in to another (then that in to another, to another and to another if needed). You can easily give your scripts a simple GUI interface using programs like kdialog.

Beginners Guide:
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
Advanced
http://tldp.org/LDP/abs/html/

lumak 11-26-2008 01:43 PM

in regards to piping output using bash, you then have to have working knowledge of 'sed' and '(g)awk' (assuming you need any type of string manipulation beyond the capability of bash variable substitution methods) Knowing 'bash' simply isn't enough. You have to know the basic programs available to you (which I'm sure you will find out all the details of with any type of training manual/course). Most definitely, learn bash's variable substitution methods before touching sed and gawk. You can avoid using either of those in some cases.

arizonagroovejet 11-26-2008 01:47 PM

Good point about sed and (g)awk. The bash guides I linked do cover both of those to some degree.

dive 11-26-2008 02:18 PM

+1 for bash, sed and awk.

chrism01 11-26-2008 06:46 PM

Definitely learn bash, its the cmd line default. Also at least the basics of sed/awk or have a good ref handy.
For more powerful stuff, Perl is very popular. There's even an O'Reilly book 'Perl for System Administration' http://oreilly.com/catalog/9781565926097/

You can also do web content with Perl, or use php.

Here's a few links:

http://rute.2038bug.com/index.html.gz
http://www.tldp.org/LDP/abs/html/
http://perldoc.perl.org/
http://www.perlmonks.org/?node=Tutorials

good luck

salasi 11-27-2008 05:04 AM

There are various things that you might want, but you will need at least simple bash scripting.

You could say I'm prejudiced because I like Python, but, irrespective of that, I think in your situation, you should learn at the very least some basic bash first. There are some circumstances in which bash (plus sed, grep, awk, as mentioned earlier) is the only reasonable solution for a sys admin, so really the question is, what to do after that; "advanced" bash, Perl or Python? You'll get people arguing for each and none of them is bad. Maybe you'll have developed your own preference by then.

max_cherry 11-27-2008 09:29 AM

Thanks a lot Guys. This puts things completely into perspective. Very much appreciated.:cool: :study:

Fritz_Monroe 11-27-2008 09:35 AM

I'll put my vote in for bash as well. There's so much admin work that can be accomplished with bash. Then when you are comfortable at least with the basics, move onto Perl or Python.

makyo 11-27-2008 12:04 PM

Hi.

Any of the references cited for bash, and, if you want a smattering of many, with examples that you can enter and test:
Code:

Title: UNIX(R) Shells by Example
Subtitle: ... guide to the C, Bourne, and Korn Shells plus Awk, Sed, and Grep
Author: Ellie Quigley
Edition: 4th
Date: 2004
Publisher: Prentice-Hall
ISBN: 013147572X
Pages: 1200
Categories: sh, csh, ksh, grep, sed, awk, scripting, shell, programming
Comments: 4.5 stars, 50 reviews Amazon (2008.11)
Comments: ( I have 2nd Ed, 1997; 4th covers also bash )

Best wishes ... cheers, makyo

mwarnock 11-27-2008 12:47 PM

One more for bash, but perl over sed/awk
 
I agree that bash is essential to any system administration task. It is the natural extension of the command line you use all the time, and uses all the same constructs, commands and environments. So start there.

However, if you want to massage text, don't waste your time with sed and awk. They are too "awk"ward, hard to learn, limited, etc. Perl is easier to learn and use, and far more powerful, and the available library packages lend themselves to solving lots of problems that sed/awk never could. Perl uses all of the "regular expression" power of sed and awk, and then some, but goes far beyond them. I use either bash or perl almost all the time for any system administration job.

Perl follows very closely and further enables the Unix "tool" philosophy of small tools that can be piped together to accomplish bigger jobs, operating on standard text data in the pipeline, as sed and awk do. But it adds much more flexibility and power.


All times are GMT -5. The time now is 08:38 PM.