![]() ![]() |
Dec 16 2004, 06:21 PM
Post
#1
|
|
|
Group: Members Posts: 554 Joined: 19-April 04 From: Keokuk, Iowa Member No.: 2,897 |
I'm a UNIX/Linux shell scripting newbie. I've seen a few Zaurus User Group How-To pages on some script examples and I think I unterstood 85% of what I saw...
|
|
|
|
Dec 16 2004, 10:17 PM
Post
#2
|
|
|
Group: Members Posts: 66 Joined: 22-February 04 Member No.: 1,946 |
Since you mentioned understanding about 85%, I suggest grabbing a copy of "The Advanced bash Scripting Guide" and installing it, and the free version of cygwin, on your laptop. Those will give you a good opportunity to teach yourself scripting (and the use of command-line tools in general), and the Guide makes a superb reference.
I don't know how many different shells are available for Linux. Certainly bash is the most popular. There are some similar, but less-featureful shells, like sh and ash, that are commonly used in resource-constrained environments. There are multiple variants of the C shell, designed to make C programmers comfortable. And there are others, like the Korn shell, that exist just because people got used to their idiosyncracies under *nix and they were easy to port. It's a lot like editors: there are a few cases where one particular choice is objectively better (like when you're making a rescue system that boots from one or two floopies, and every byte counts), but it's mostly a matter of taste. Ran |
|
|
|
Dec 16 2004, 10:27 PM
Post
#3
|
|
|
Group: Members Posts: 207 Joined: 7-July 03 From: Thousand Oaks, CA Member No.: 9 |
To add to what ran posted just as I was getting ready to hit "Reply"
Choice of shells is largely a matter of personal preference: some prefer one set of features or style of syntax over another. Another factor is whether or not a particular shell is likely to be found under different OS environments or not. The sh shell is ubiquitous and can be found on every *nix like platform, but lacks some of the more advanced features (history editing, for example) of the somewhat more "bloated" shells like csh or bash. Both bash and sh appear to be standard on all versions of Linux that I've encountered thus far, but you can usually add ash, ksh and so on. The "Advanced Bash-Scripting Guide" that ran mentioned is a good resource and can be found at: http://www.tldp.org/LDP/abs/html/index.html among other places. Also, "Bash Reference Manual" at http://www.gnu.org/software/bash/manual/bashref.html |
|
|
|
Dec 17 2004, 10:56 AM
Post
#4
|
|
|
Group: Members Posts: 992 Joined: 9-October 03 From: NYC Member No.: 609 |
QUOTE(TonyOlsen @ Dec 16 2004, 09:21 PM) I'm a UNIX/Linux shell scripting newbie. I've seen a few Zaurus User Group How-To pages on some script examples and I think I unterstood 85% of what I saw...
(1) There are no shell script extensions -- anything that is in place is just to be nice. (2) There are none, since extensions aren't used. (3) Oh, you mean shells! (4) best is internet -- there's one ... shell programming gems, let me see what I can find. http://www.spy.org/programming/sh/as-txt Basically, the command interface for unix... is called a shell -- but really this "shell" is just a way to launch commands. Shells can be brain-dead simple, or they can get overly-complex. Traditionally, unix has had "sh" for root and system accounts and scripts, but you will see that linux is probably using bash and I think freebsd is using tcsh (for root's shell) -- but most scripting is done using /bin/sh -- because it's pretty standard. Of course, /usr/bin/perl is also pretty standard -- although I remember when it wasn't, etc. If you program in plane-jane "sh" (no ksh extensions, etc) ... you might be able to get some cross platform compatibility -- but it isn't guaranteed. sh is decent for programming, but is severely lacking in some areas such as math and advanced data types (ie: arrays?) ... csh is more user friendly than sh for interactive use, but it's really a mess for programming. I don't think anyone really programs in csh, although I did write a BBS once in tcsh. I have used tcsh for my shell since the late 80s....but I've been meaning to switch over to zsh. I'm starting to put zsh into use on different machines now, but zsh may not be installed "standard" on many machines -- the same is probably true os tcsh. There are many other "shells" out there -- and you could even make your own. Just about any program that has a command interpreter in it could probably be used as a shell (ie: I know someone who had emacs as their login shell -- and I had perl as my login shell for a while... recently I was looking into Ch as my login shell). As far as programming, the net is probably the best resource to find examples of programs. There are few gotchas with sh programming compared to other languages (ie: setting var values a while loop doesn't work -- sometimes -- because a child can't affect the parent [without a specific arrangement to do so]). Feel free to ask questions here if you are stuck with something regarding shell programming. Scott |
|
|
|
Dec 17 2004, 12:33 PM
Post
#5
|
|
|
Group: Members Posts: 125 Joined: 5-October 04 Member No.: 4,882 |
Scott - re: perl shell
Did you have your login shell run perl -e? Was it actually useful? How'd it work? Fun. -Daniel |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 18th May 2013 - 03:06 PM |