Shell Scripts
Rejean Proulx
rejean at interfree.ca
Sat Nov 8 16:25:22 EST 2003
That is why I was getting so pissed off. I'll move them to my bin in local.
I found a nice package called fauback which backups file incrementally. I'm
making myself a system backup schedule and then I'll make a MYSQL table
schedule. That is major as there are 30 to 40 tables.
Rejean Proulx
Visit my family at http://interfree.ca
MSN is: rejp at rogers.com
Ham License VA3REJ
----- Original Message -----
From: "Luke Davis" <ldavis at shellworld.net>
To: <Speakup at braille.uwo.ca>
Sent: Saturday, November 08, 2003 3:49 PM
Subject: Re: Shell Scripts
> Oh, something else you have to know about scripts, is that they have to
> either be in a bin directory (such as /usr/local/sbin, or /root/bin (if
> that is in your path)), or you must specify the path, even if it is in the
> current directory (for example: "./myscript").
>
> Now, here's a more advanced version of my previous script. It deletes all
> files given to it on the command line, and then edits new files with those
> names, in turn:
>
> Warning that this is highly untested, and I may have forgotten something.
>
> #!/bin/bash
>
> # See if the first commandline parameter is empty
> if [ "$1" == "" ]; then
> echo "You didn't specify any files!"
> exit 1
> fi
>
> # conditionally delete the files
> rm -i $@ && \
> # If the rm was successful, print this
> echo "All files deleted..." || { \
> # Otherwise, enter a command sequence, and start by outputting this
> echo "There was a problem deleting the files; exiting..."
> # Exit the program
> exit 2
> # End the command sequence
> }
>
> # Output the following, with no carrage return at the end
> echo -n "Press enter to start editing the files."
> # Read what the user types into the variable "$dummie"
> read dummy
>
> # Start a loop conditional
> while ;
> # Start the loop of commands; and assign the first parameter to $curname
> do curname=$1
> # Edit the file listed in $curname
> nano $curname
> # Put the first parameter into $lastname
> lastname=$1
> # Move all of the command line parameters one parameter to the left, so
> # that $2 is now $1, $3 is now $2, and so on
> shift
> # If the new $1 is empty, exit
> if [ "$1" == "" ]; then break;
> # Or, if the previous name, and the current first parameter are the same,
> # leave the loop
> elif [ "$lastname" == "$1" ]; then break;
> # Otherwise, start over with the new parameters
> else continue;
> fi # Leave the if statement
> done; # Leave the while do loop
>
> exit 0; # Leave the program with success
>
> Luke
>
>
>
>
>
> On Sat, 8 Nov 2003, Rejean Proulx wrote:
>
> > I have a bunch of MYSQL tables and files to back up. I want to write
some
> > scripts that call functions so that I can reuse them. I need to have a
> > script that gets called like this
> >
> > backsql tablename weekly
> >
> > Table name and weekly are 2 parameters. In dos we use to code that with
%1
> > %2 or maybe it was just numbers. How do I pass parameters to a script?
I
> > need a sample to work from so I can get started. Then I can read
manuals.
> > What file names do I use in Linux. Would it be backmysql.sh or
something
> > like that?
> >
> > Rejean Proulx
> > Visit my family at http://interfree.ca
> > MSN is: rejp at rogers.com
> > Ham License VA3REJ
> >
> >
> > _______________________________________________
> > Speakup mailing list
> > Speakup at braille.uwo.ca
> > http://speech.braille.uwo.ca/mailman/listinfo/speakup
> >
>
> _______________________________________________
> Speakup mailing list
> Speakup at braille.uwo.ca
> http://speech.braille.uwo.ca/mailman/listinfo/speakup
More information about the Speakup
mailing list