View Single Post
  #4  
Old 19th November 2011, 00:59
nerdhacker nerdhacker is offline
Junior Member
 
Join Date: Nov 2011
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Mark, very usefull your script, i already fix mine with something similar that you post

the script looks now like this and works just as i want
Code:
#!/bin/sh

echo "Checking if exist internet connection"

ping -c 3 www.google.com

if [ $? -eq 0 ]; then

  echo "Starting to send & download email"

  echo "Flushing mail queue"

  /usr/sbin/postqueue -c /etc/postfix -f

  echo "Starting fetchmail"

  /usr/bin/fetchmail -v -f /etc/fetchmailrc -L /var/log/fetchmail.log

  echo "Checking mail queue and fetchmail process"

  while ! postqueue -p | grep -q empty && ps -C fetchmail > /dev/null; do

    echo "There is still mail in queue or fetchmail is still working"

    sleep 1

  done

  echo "Terminating the connection"

  killall wvdial

fi

echo "Internet connection not found"
now i have another issue. as this script runs automatically when ppp0 comes up and not manually or by a cron job, how can i see the output of this script when it runs? may be logging it to some file under /var/log or there is some other way to see it when it is running? how this can be done?
Reply With Quote