General Question

monsoon's avatar

How are shell scripts applied in Computer Science?

Asked by monsoon (2483 points ) April 21st, 2009

I’m sort of in my first semester of CS classes, and am seriously loosing heart in my UNIX class. It seems really easy, but also I can’t see any point in it. Just a whole class teaching you things that would only take you a few minutes to find out yourself when necessity called.

My real question is this: Will I ever need to use shell scripts in real life? I want to work in software development eventually, but I just saw a really great job for which one of the requirements was knowledge of shell scripting, and I can’t see how that would be used. I would just like to know of a practical example of their use, maybe to help me be a little more motivated to learn.

Thanks.

-m

Observing members: 0 Composing members: 0

22 Answers

cwilbur's avatar

Shell scripting is one of the ways you automate things. It’s essential for things like build process automation.

Although, if you’re in a degree program that purports to be computer science, your first semester shouldn’t be vocational training in Unix, but the rudiments of programming. Perhaps you’re in the wrong program?

MrItty's avatar

I’m a software engineer. Actual shell scripts in the production evironment are about 10% of my overall responsibility. Far more common is what we call “one-off” shell scripts. A script you write for an immediate need, to do some research on a specific issue.

We have shell scripts to…
* print out the date in yyyy-mm-dd format of a specified number of days ago
* source an environment file and setup configuration directories before kicking off the main script (which is in either Java, Perl, or C++)
* communicate via signal handling with continuous-running processes
* obtain the status (file counts, for example) of various directories as the processing day continues.
* standardize a logging system for use by all applications, regardless of the language in which they’re written.

There are more examples. Those are off the top of my head.

MrItty's avatar

@cwilbur Why are you assuming he’s taking only one class? He’s talking about ”[his] Unix class”, not the entirety of his first semester. I see absolutely nothing wrong with a CS cirricula that includes both programming (either C++ or Java) and Unix fundamentals in the same semster, in different courses.

monsoon's avatar

@cwilbur, yes, I’m taking both Unix and intro to programming (C++) this semester, they’re meant to be taken concurrently. And

@MrItty, thanks, that’s really helpful. I can’t say that I know what all of that means, but I get the idea. It’s good to know I’m learning things that are useful.

cwilbur's avatar

@MrItty: because I know of very few decent to great computer science programs that put such a huge emphasis on vocational training.

lercio's avatar

Have you ever run one of those neat configure scripts that write the make files to compile and install UNIX software. That’s a shell script, and a good example of use in software development.

phoenyx's avatar

It probably is something that could easily do for yourself. However, would you want to do it every day at 1:00 AM? Where I work we have stuff like that. I rarely do bash scripting, but when I do, it is for a cron job that I don’t want to have to bother with.

MrItty's avatar

@cwilbur “Such a huge emphasis”? Where are you getting this from? The kid is talking about one course during his freshmen semester of learning shell scripting.

This is not 15–20 years ago. People who grew up with computers who will eventually go into Computer Science do not learn Unix natively. They do not grow up knowing how to do basic Unix commands. They’ve never telnetted to a web server, used a command-line FTP program, or done anything else that involves an input method other than the mouse. They have to learn Unix when they get to college, because they’ve had no experience with it previous to that point in their lives.

(Tangent, but true story – 8 years ago, when I started teaching Perl, I put up Intro to Unix slides on the course website, and told those not familiar with Unix to review them on their own time. I went over the absolute basic commands, and gave their equivalents to DOS commands that the students would already know (rm => del, cp => copy, etc). Flash forward 8 years, and now I have students telling me those equivalencies don’t help them, because not only have they never used Unix, they’ve never used DOS commands either. They’ve never done anything on their computers’ filesystems that didn’t involve using Windows Explorer and the mouse.)

cwilbur's avatar

@MrItty: I’m talking about schools like MIT, Stanford, CMU, Columbia, Harvard, Yale.

A class in basic Unix commands is vocational training, not computer science, and if it’s offered as a for-credit course, it’s taking up space in the catalog and the schedule that would be far better used for courses in algorithm analysis, parallel algorithms, compilers, parsing, computer language concepts, hardware architectures, and the like. As Edsger Dijkstra famously commented, computers have the same relationship to computer science that telescopes have to astronomy.

Now, I’ve seen a lot of schools that offer a full four-year program of teaching the syntax of various languages, possibly with a basic algorithms course thrown in. That’s vocational training in programming, if that, and not anything resembling computer science. English students need to know how to use a word processor, too, but if English departments everywhere started offering for-credit courses in Microsoft Word, I’d point and laugh at them too.

MrItty's avatar

Fascinating how not a single thing in your post actually replied to anything in my post.

As you continue to thumb your nose at what you refer to “vocational training”, do you operate under the belief that people don’t actually need to learning languages and operating systems in order to apply knowledge learned in Algorithms, Analysis, and the like? Or do you think “real” computer science is simply theory and not application?

How’s the job market today for folks who can think up algorithms in their sleep but haven’t a clue how to actually write a program?

(FWIW, I graduated from and teach at RPI. Not up to MIT’s standard, I grant you, but we’re no slouch either)

robmandu's avatar

My university computer science B.S. program involved much more theory (finite automata, discrete math, numerical methods, data structures) than practice (Java, C/C++, Fortran). And at no point did we cover system administration for any O.S. Freshman had an intro. to UNIX course just to learn how to signon to the university workstations, get around in emacs, etc. But as for the “vocational” part, we were expected to pick that up on our own time.

cwilbur's avatar

@MrItty: I think someone who has a solid computer science education will pick up languages trivially easily, while someone who has vocational training in the two languages of the day will struggle mightily with new concepts. Yes, you need to learn the basics of a language in order to learn the rudiments of algorithms, but spending six semesters learning the syntax of three currently popular languages is a total waste of time.

I reiterate my comparison: English majors need to know how to use word processors. This doesn’t mean that they teach Microsoft Word as a for-credit course in the English department. Computer science majors need to know how to use Unix at the shell level. This doesn’t mean that they should be teaching Unix rudiments as a for-credit course. And the better computer science departments don’t teach Unix rudiments as a for-credit course—they have enough other stuff to teach that they don’t spend credit-hours on it.

The job market for folks who can think up algorithms and data structures in their sleep but can’t code is actually quite good—they’re called software architects. They get paid considerably more too. One software architect is easily worth 10 code monkeys who know Java syntax but not much more—because the code monkeys are often interchangeable, especially if all they can do is code, but the architect understands the way things work and the way things fit together.

My experience was much like @robmandu‘s—I was formally taught Pascal in the introductory programming courses, and it was used as a lingua franca for expressing algorithms throughout the department. In the programming languages course, I got tastes of C, Fortran, Eiffel, MIPS assembler, Prolog, Lisp, and Smalltalk—we spent about two weeks on each of them, and we were expected to be reasonably fluent in all of them on our own. The only language that I have used professionally that even existed at the time I finished school is Perl – and it was Perl 4, not Perl 5.

And I don’t think there’s anything inherently wrong with vocational training in programming. I just agree with Dijkstra that it has about as much to do with computer science as optics have to do with astronomy—you have to get it right if you want to really get anywhere, but to focus on it is to completely miss the point.

MrItty's avatar

Where in the HELL did you get this “six semesters learning the syntax of three currently popular languages” nonsense? Now you’re just making stuff up, pulling random things out of the air and pretending you’re actually arguing something.

So you were taught Pascal in the introductory course. Congrats. I was taught C++ in an introductory course. Guess how often I use C++? Almost never. This guy is being taught Unix Shell in an introductory course. What is the difference in your mind? Where is this nose-in-the-air attitude coming from?

Where is this idea of “focus” on the introductory stuff coming from? We’re talking about one course, in his first semester. The same damn thing you did with Pascal, yet you continue to persist that this kid’s program is “wrong”.

cwilbur's avatar

@MrItty: I’ve seen college curricula where six full semesters are spent on the syntax of three currently popular languages. I am not making this up. This was called a “computer science” degree. I am not making that up either.

I am not aware of any curriculum anywhere that uses shell scripting to teach the rudiments of programming—principally because many of the rudiments that need to be grappled with eventually, such as memory management, are not available in shell, and others, such as recursion and indirection, are so difficult to accomplish. In your case, C++ was taught in order to get to these concepts. In my case, Pascal was taught in order to get to these concepts. If shell is being taught as a way of getting at these concepts, it’s a really moronic choice; if it’s not being taught as a way of getting at these concepts, it’s a waste of classroom time and credit hours in a computer science degree.

And I’m not claiming so much that the kid’s program is wrong, but that if his classes are offering principally vocational computer training, that calling it a computer science degree is inaccurate.

MrItty's avatar

@cwilbur You have changed what you’re trying to argue so many times that it’s not worth it to continue the discussion. Every fact I refute, you ignore. Every fact I point out, you simply change your original point. This latest is you’re changing your story from “Perhaps you’re in the wrong program”, to “I’ve seen other programs that are bad”. There is no point debating or arguing with someone like that. Fare thee well.

cwilbur's avatar

You haven’t refuted a single thing; you’ve just implied that I’m an elitist. If you feel inferior because I distinguish between computer science and vocational training in programming, I suggest you seek therapy.

monsoon's avatar

@cwilbur

1. Thanks for bashing my school, nice. You’re obviously a classy guy.

2. I’m double majoring and have three jobs; I’d be pissed if my classes expected me to learn Computer Science on my own time. At least I’m getting what I’m paying for.

3. My Unix course is not a fully credited course.

4. Sorry I couldn’t go to MIT. Don’t say you’re not an elitist when you are. Own it.

5. English majors = Computer Science majors : Microsoft Word = Unix? Seriously? That’s a stretch, as anyone who attends a University probably knows how to use Microsoft Word, and if they don’t, it has a learning curve of about half an hour.

6. I don’t have any classes based on Languages. My intro to programming centers on C++, but it isn’t a C++ course. We are simply using C++ to illustrate introductory concepts.

Now, it’s doesn’t matter much to me whether any of this matters to you, I simply wanted to set some of these wild insinuations straight.

Also, I’m a girl.

cwilbur's avatar

I am an elitist. Why would I settle for second-class things? Why would anyone?

You mentioned that you were learning shell scripting in an introductory class, and that you thought you could pick it up easily outside class. I agree wholeheartedly, and I think it’s a sign that your program is likely to have the wrong emphasis for a computer science program.

Ask yourself: are you in school to learn computer programming and maintenance, or computer science? Own your answer. If it’s the former, you’re likely to be happy where you are. If it’s the latter, you’re likely to be disappointed and frustrated.

mattbrowne's avatar

I’m a computer scientist (graduated in 1989). And I can assure you: shell scripts are very, very important. Even if Unix gets replaced by something else eventually, the mere concept will stay. It’s worth spending lots of time on the subject and you won’t regret it. This doesn’t mean you should learn Java and PHP and Python and whatever as well.

noyesa's avatar

I’m a web developer who uses Mac, and I use shell scripting all the time. I write most of my scripts in Ruby and Python, but the general idea of shell scripting and the application in Unix environments is near universal, i.e. you can do it using any scripting language that your computer knows how to understand. Mac, out of the box, understands scripting in PHP, Python, Ruby, and Perl. Bash is generally very lenient, so you can script in whatever your native tongue is. AppleScript is also a neat alternative. It’s an extremely expressive and easy to grasp language (almost confusingly so at first) that you might find yourself using if you do use or will ever use Mac. I assume the same applies to other Unix systems.

monsoon's avatar

@noyesa, I’m a Mac user myself. My other Mac-using classmates and I laugh at the Windows users downloading Cygwin and partitioning their laptops with Linux (nothing against linux) so that they can practice what we’re learning.

Just finished that class, btw, thanks for your input.

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther