sudleyplace |
03-11-2008 09:46 AM |
Trouble With FOR Loop In Simple Bash Script
I thought I copied the following script correctly, but it doesn't seem to work. In particular, although I can type ps auxww | etc at the command line and get a PID, the for loop in the script doesn't run:
Code:
#! /bin/bash
#
echo -n "Stopping rsyncd: ";
for pid in $( ps auxww | grep "rsync" | grep -v grep | grep -v pico | cut -c10-14 );
do
kill -9 $pid;
rm -f /var/lock/rsyncd.lock;
echo "[ OK ]";
exit;
done;
echo "[ FAILURE ]";
1. Why doesn't the for loop run?
2. Do I need all those semicolons?
3. After you get this working, do you see any way to simplify it?
4. Is there a tutorial on shell scripts which covers the concepts I've missed?
|