UNIX supports a fairly sophisticated programming language in its command interpretter. You can use it to automate anything you'd normally do "by hand", and provide error checking while doing it. If you've used traditional programming languages, you'll see a lot of familiar control structures. If you've never programmed before, you'll get familiar with a lot of traditional programming concepts.
Related topics: Unix text editors; Setting file permissions; {P}The UNIX path
It's true, but misleading, to say that shell scripting is simply a matter of making a file which contains the commands you'd normally type, and then making that file executable. While misleading, it's a helpful starting point. As a first, trivial example of a shell script, we'll use a simple sequence of commands. If you have a file that says:
echo running a script mkdir /tmp/jones mv ~/mail/sent-mail /tmp/jones/sentmail cd /tmp/jones zip -a world
You can make that file executable with the chmod command. Say it's named "zipsent". You'd run:
world% chmod u+x zipsentTo make it executable by the user who owns it (that's you). After you've done so, you can run that series of commands by typing in the name of the file at the world% prompt. Note that if any of the commands fail -- say there's already a directory named "/tmp/jones", so the mkdir command fails -- the script won't care, it will just continue on to the next command.
HOME Top of Help Desk Eye On The World The World Kiosk
For further assistance, please send an email
request to support@world.std.com
Copyright 1996 Software Tool & Die, Inc. All Rights Reserved.
Software Tool & Die, Inc., 1330 Beacon St. Suite 215 Brookline, MA 02146