[EMAIL PROTECTED] wrote:
>
> I wonder if anyone knows of a source for example bash scripts? I've read
> the man page several times and it covers so much I'm not able to digest
<snip>
Print out the man page. It helps!
Also look at your startup-scripts in /etc/rc.d odr /sbin/init.d. They
show most of the functionality of bash.
> learn. Just some examples of what can be done with "while/do",
> "until/do" and "if/then/else" would get me started.
<snip>
What I find useful, is the for-loop and command substitution:
#!/bin/bash
for i in $(locate '*.dvi'); do
cd $(dirname $i)
dvips -f < $i > /dev/null
done
creates all needed fonts for TeX to view all .dvi files currently on
your system.
This is what I start my setiahome clients with:
#!/bin/bash
SETIHOME=$HOME/setiathome
until [ -f setiathome-1/RAN -a -f setiathome-2/RAN ]; do
for i in 1 2; do
cd "$SETIHOME/setiathome-$i"
if [ ! -f RAN ]; then
touch RUNNING
echo "Starting SETI@Home #$i"
./setiathome -nice 19 -stop_after_process
rm RUNNING
touch RAN
fi
done
done
echo 'Need refresh!' | mail -s "setiathome wants refresh..." $USER
and this is what I have in my ip.up script to flush seti's buffers:
# flushing seti@home client's buffers
for i in 1 2; do
cd /home/mmutz/setiathome/setiathome-$i
if [ -f RAN ]; then
su mmutz -c './setiathome -stop_after_xfer'
rm RAN
fi
done
Isn't shell scripting a wonderful art?
Marc
--
Marc Mutz <[EMAIL PROTECTED]> http://marc.mutz.com/
University of Bielefeld, Dep. of Mathematics / Dep. of Physics
PGP-keyID's: 0xd46ce9ab (RSA), 0x7ae55b9e (DSS/DH)