The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
script running with "ksh" dumping core but not with "sh" simhe02 HP-UX 8 05-22-2008 02:46 AM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-19-2007 09:52 PM
passing a list of dynamic names to a "PS" command in shell script? sachin.tendulka Shell Programming and Scripting 3 11-21-2007 12:18 AM
Q: Recording shell script screen output using "script" command ? lalfonso.gomez Shell Programming and Scripting 4 01-18-2007 05:31 PM
Unix "at" / "Cron" Command New Problem...Need help Mohanraj UNIX for Dummies Questions & Answers 3 01-26-2006 04:08 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-04-2005
Registered User
 

Join Date: Mar 2005
Posts: 1
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!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-07-2005
Registered User
 

Join Date: Mar 2005
Posts: 29
maybe you want like this:
Code:
objIp=127.0.0.1
/usr/sbin/ping $objIp 5 >/dev/null && echo "$objIp is alive" || { echo "$objIp isn't exists"; exit 0; }
Reply With Quote
  #3 (permalink)  
Old 03-07-2005
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,221
echo "$script prealert $2" | at now + 2 minute
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:41 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0