A couple of notes about your code:
#!/usr/bin/bash
curl ftp://Sterst:abh89TbuOc@############################/Test/| wc -l ;
read b;
That does not do what you think it does: the wc
output goes to stdout, not into the read
command. Do this instead: b=$( curl ... | wc -l )
a=9
if [ "$b" != "$a" ];
Since the wc
output will have some extra whitespace, better to do a numeric comparison:
if (( a != b ))
then
echo "FTP dir has modified mail" -s "dir notification" sni912@######.com;
You probably mean this:
echo "FTP dir has modified" | mail -s "dir notification" sni912@######.com;
I would write this:
listing=$( curl ftp://... )
num=$( echo "$listing" | wc -l )
if (( num != 9 )); then
mail -s "ftp dir modification" email@example.com <<END
FTP directory modification
$listing
END
fi