Script scheduling problem using "at" command

Hello!

I'm writing a shell script that will monitor if a server is up or down.

I would like to use the command "at" inside of my script to reschedule the script to run in 2 minutes but I can't pass parameters to my script and this is my problem...

This is the idea behind the script:

  1. The script run in "normal mode" and check if the server is up. If the server is not responding, the script go to step 2.

  2. Schedule itself to run in two minutes in "prealert mode"

  3. When running in "prealert mode", the script check if the server is still not responding and if not, send a alert to the network administrator.

Does anybody know how to pass parameters to a commmand or script while using the "at" command. I know I can put everything in a file and make at use that file but I would prefer not to... Any suggestion?

Syntax example to execute the script:

./test_ping prealert server1.test.com

Here is a sample of my script:

#!/bin/bash
#Script to test network connectivity
#By Benoit Charbonneau
#March 4th 2005
#Parameters ex.: test_ping mode(normal|prealert) server

log="../monitoring.log"
date=$(date)
path=$(pwd)
script=$path/test_ping

ping -c1 -w2 $2 > /dev/null
error=$?

if [ $1 = "normal" ]; then
if [ $erreur != 0 ] ; then
at -f "$script prealert $2" now + 2 minute
# My problem is here
echo $date $2 ping error - A prealert has been open >> $log
else
echo $date $2 ping ok >> $log
fi
fi

if [ $1 = "prealert" ]; then

...

Sorry if i'm not clear enought. English is not my first language...

Thank you for your help!

maybe you want like this:

objIp=127.0.0.1
/usr/sbin/ping $objIp 5 >/dev/null && echo "$objIp is alive" || { echo "$objIp isn't exists"; exit 0; }

echo "$script prealert $2" | at now + 2 minute