I have a script that's failing
./zzmaster.sh: line 2: syntax error: unexpected end of file
There are 4 scripts total involved. The first 'znocc0.sh' essentially curls a page then does some sed sequences...
#!/bin/sh
#GET SENTINAL INFO
curl -b z0cookie.txt -L -k -e http://4phpfreaks.freehostia.com/index.html -A "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9
.0.4) Gecko/2008102920 Firefox/3.0.4" -L "http://4phpfreaks.freehostia.com/index.html" > shell.html
#cut for brevity - I do several manual sed sequences in between
#then for the more advanced, I call it seperately..
./zrmtd0.sh &&
mv ztmp.Ps23zp2t.2-Fpps3-wmmm0dss3 shell.html
./zrmtd0o.sh &&
mv ztmp.Ps23zp2t.2-Fpps3-wmmm0dss3 shell.html
The zrmtd0 and zrmtd0o scripts just chop up table data to trim out some of the uncessary baggage. They are both the same just cutting out different table datas.
#!/bin/sh
IN=0
CT=0
OUTFILE="ztmp.Ps23zp2t.2-Fpps3-wmmm0dss3"
echo > $OUTFILE # Start with fresh file always
cat shell.html |while read LINE
do
# If we are entering a table row the we need to reset the TD counter
TR=`echo $LINE |grep -i '<tr'`
if [ -n "$TR" ]
then
CT=0
else
echo "" > /dev/null
fi
# Check to see if the LINE is non-empty, and has an opening td tag in it.
TD=`echo $LINE |tr -d '\n' |grep -i '<td'`
if [ -n "$TD" ]
then
# We are inside a td tag.
IN=1
fi
# Check to see if the LINE is non-empty and has a closing td tag in it.
ENDTD=`echo $LINE |tr -d '\n' |grep -i '/td>'`
if [ -n "$ENDTD" ]
then
# We are leaving a td tag.
IN=0
# Increase the TD counter by 1
CT=`echo "$CT+1" |bc`
fi
if [ "$IN" -eq 1 -a "$CT" -eq 6 -a -z "$ENDTD" ]
then
# Use sed to remove this TD tag AND everything in between
echo $LINE |tr -d '\n' |sed 's/.*//' >> $OUTFILE
elif [ "$IN" -eq 0 -a "$CT" -eq 7 ]
then
# We may (or may not) have an opening and closing td tag in 1 line.
TMP=`echo $LINE |tr -d '\n' |sed 's/<TD.*//'`
echo $TMP |sed 's/.*\/TD>//' >> $OUTFILE
else
echo $LINE >> $OUTFILE
fi
done
BUT HERE IS WHERE MY PROBLEM LIES.. I create a file called zzmaster.sh with this line..
sh /home/jim/www/htdocs/curl/replicate/znocc0.sh &&
and it breaks with the error
[jim ~/www/htdocs/curl/replicate]$ ./zzmaster.sh
./zzmaster.sh: line 2: syntax error: unexpected end of file
[jim ~/www/htdocs/curl/replicate]$
Why? Eventually I'd like to reference several of these and just run a cron on that one file while sleeping once or twice in between...
sh /home/jim/www/htdocs/curl/replicate/znocc0.sh &&
sh /home/jim/www/htdocs/curl/replicate/znocc1.sh &&
sleep 20
sh /home/jim/www/htdocs/curl/replicate/znocc0.sh &&
sh /home/jim/www/htdocs/curl/replicate/znocc1.sh &&
sleep 20
sh /home/jim/www/htdocs/curl/replicate/znocc0.sh &&
sh /home/jim/www/htdocs/curl/replicate/znocc1.sh &&
At first I started the script with #!/bin/sh. It complained so I took it out. So now it just complains of the last line. Now aside from the current error, since the script -technically, when I go to configure the cron it breaks... Here's the complaint cron gives me..
mydomain.net : Dec 24 23:42:06 : jim : /usr/local/etc/sudoers is not a regular file ; TTY=ttyp1 ; PWD=/home/jim/www/htdocs/curl/replicate ; USER=root ; COMMAND=root
And here's the cron..
## replicate
* * * * * root /home/jim/www/htdocs/curl/replicate/zzmaster.sh
When I run the command directly as root, it doesn't complain at all. In fact, the first error doesn't come up.
jim# /home/jim/www/htdocs/curl/replicate/zzmaster.sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1154 100 1154 0 0 6929 0 --:--:-- --:--:-- --:--:-- 0
him#
I'm baffled right now. Could someone help please?