a little script
Tim Writer
tim-s/rLXaiAEBtBDgjK7y7TUQ at public.gmane.org
Tue Jan 27 15:48:45 UTC 2004
Chris Aitken <aitken-BwLjziHGQLusTnJN9+BGXg at public.gmane.org> writes:
> Paul Mora wrote:
> >
> > Here's a very simple example script to do what you want (I know, I'll
> > probably be flamed by the scripting experts out there):
> >
> > #!/bin/bash
> > #
> > # Simple script to stop printing services and unload the parallel
> > # port module
> > service cups stop
> > modprobe -r lp
> > exit 0
>
> I type all that into vi?
Any text editor, vi is fine.
> Are the #'s remarks or do they represent the command
> prompt ($ on my rh 7.3 system)?
They are remarks (comments).
> This file in the example I would save as
> myscript.sh and run it by typing myscript.sh or ./myscript.sh or $
> !myscript.sh or some such?
You can give it any name you want, it does not have to have a ".sh"
extension. If you save it as myscript.sh in your home directory for example,
you would run it as:
./myscript.sh
when in your home directory. To run it from somewhere else, any of:
~LOGIN/myscript.sh
/home/LOGIN/myscript.sh
where LOGIN is replaced by your login name, should work. If you need to run
it often, you should copy it to a directory in your path (or in this case,
root's path since you're going to be running it as root). A good place would
be /usr/local/bin. Then you can just run:
myscript.sh
> > To learn shell scripting, you can get any number of Bash shell
> > programming books, available from Oreilly and other publishers. There's
> > also a real good shell programming book called "Advanced Bash Shell
> > Scripting" available at http://www.tldp.org/LDP/abs/html/. You can also
> > get it in a downloadable PDF format.
You can also study a lot of the shell scripts which make up a typical Linux
system. Some of them are complex but a lot of them are remarkably simple.
Take a look at the start/stop scripts in /etc/init.d or /etc/rc.d/init.d
These scripts are responsible for starting and stopping system services which
is one reason why:
> > Understanding the basics of shell scripting extremely useful.
--
tim writer <tim-s/rLXaiAEBtBDgjK7y7TUQ at public.gmane.org> starnix inc.
905.771.0017 ext. 225 thornhill, ontario, canada
http://www.starnix.com professional linux services & products
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list