Nick and Eric and I were talking after the meeting last night,
and Nick mentioned that we should do "pet scripts", i.e. scripts
that aren't very big, but that we find really useful. Almost
everyone has a script that they use a lot that might fit into
this category.
So I am boldly putting forward my first pet script. It is called
'send'. I use it as a quick shorthand to send a text file to
someone, for example 'send [EMAIL PROTECTED] /etc/printcap', or
'send [EMAIL PROTECTED] *.txt'. Each text file becomes its own
email with subject: FILE: <file>.
I have two versions. My original is written for csh (tcsh works
fine):
---------
#!/bin/csh
# Sends text file(s) to an email address
if (${#argv} < 2) then
echo "USAGE: $0 user file(s)"
else
foreach file ( $argv[2-] )
mutt -s "FILE: $file" $argv[1] < $file
end
endif
---------
I have rewritten it in bash, the shell some people prefer. I
can't seem to make the script as clean because bash lacks a
foreach construct:
---------
#!/bin/bash
# Sends text file(s) to an email address
if [ $# -lt 2 ]; then
echo "USAGE: $0 user file(s)"
else
argv=($0 $@)
let i=2
while [ $i -le $# ]; do
file="${argv[$i]}"
mutt -s "FILE: $file" $1 < $file
let i=$i+1
done
fi
---------
I recommend that you replace 'mutt' in the script with the mailer
that you regularly use. The syntax for elm, mail, and mutt agree
(and I imagine pine as well). That way you will be free to use
any aliases you have defined in your mail program.
Don
--
Don Bindner <[EMAIL PROTECTED]>