Sponsored Content
Homework and Emergencies Emergency UNIX and Linux Support Script for pinging continuously Post 302970269 by MadeInGermany on Monday 4th of April 2016 03:11:52 PM
Old 04-04-2016
Jim, I don't want to start a long discussion about personal likes/dislikes, but let me state I would write it like this
Code:
#!/bin/ksh
now=`$date +%s`
stop=$(( $now +  86400 ))
while now=`$date +%s`;  [ $now  -le $stop ]
do
   if ping -c 1 -w 5 AIXservername
   then
      OK='pass'
   else
      OK='fail'
   fi
   echo "$OK at `$date`" >>mylogfile
done

The cryptic [ $! -eq 0 ] && OK='pass' || OK='fail' does unnecessary evaluation of OK='pass', and would fail if such an expression would have a non-zero exit status. In comparison, if-then-else-fi is easy to understand and risk-free.
 

10 More Discussions You Might Find Interesting

1. AIX

pinging IP's in a file

Hey all. I have a long list of IP addresses I want to ping. The IP's are located in a flat file "ping_info.dat". I was wondering what the best way to go about this would be. Can someone help me out? (2 Replies)
Discussion started by: jalge2
2 Replies

2. Shell Programming and Scripting

pinging an ip

Hi, How to ping an ip from an unix machine. Can you please let me know the exact command. I used and i got the below error ping 171.18.17.2 bash: ping: command not found Thanks n regards Ammu (1 Reply)
Discussion started by: ammu
1 Replies

3. Shell Programming and Scripting

Shell Script to continuously scan a log file

Hello members, I have some doubts on how to write a script that can reports success / failure of a batch job ? 1. Run a batch job: 2. Wait and search for a particular string in the Log file: tail -f log01*.txt | egrep -v "^SUCCESSFUL" echo "continue with the other tasks" ... (1 Reply)
Discussion started by: novice82
1 Replies

4. Shell Programming and Scripting

Forking and Pinging

Keep in mind that I haven't done Perl scripting for a LONG time, so I'm quite rusty. This is what I would like to do: - using fork, create 3 or 4 processes to read 3 or 4 different text documents containing server names or IP addresses - in each of those processes, Perl will ping each of those... (7 Replies)
Discussion started by: kooshi
7 Replies

5. Shell Programming and Scripting

Pinging a domain

how can you ping a domain and store the ip? like given a url in a variable $url how can i ping it? also how can i find the local server's ip address on a cpanel server? (i have multiple servers and didnt want to hard code it in) (basically i want to check the domain accounts on the server,... (11 Replies)
Discussion started by: vanessafan99
11 Replies

6. Shell Programming and Scripting

Run a script continuously for 10 minutes

Hi all!! Im using ksh and my OS is Linux. I want to run a script for ten minutes, starting from my current system time. How to acheive this? Any help appreciated. Thanks in advance (5 Replies)
Discussion started by: Jayaraman
5 Replies

7. Shell Programming and Scripting

Need help in running a script continuously non stop

Hi, I am running a schedular script which will check for a specific time and do the job. I wanted to run this continuously. Meaning even after the if condition is true and it executes the job, it should start running again non stop. I am using below script #!/bin/sh start: while true do... (10 Replies)
Discussion started by: sandeepcm
10 Replies

8. Shell Programming and Scripting

Shell Script for continuously checking status of a another script running in background, and immedia

Hi, I want to write a script which continuously checking status of a script running in background by nohup command. And if same script is not running then immediately start the script...please help.. i am using below command to run script nohup system_traps.sh & but in some... (9 Replies)
Discussion started by: ketanraut
9 Replies

9. UNIX Desktop Questions & Answers

Pinging Host

I need to ping websites and I need to see which one has the highest delay. My problem is I need to extract the name Facebook and the time=74.0 ms using awk. I need help doing this please... PING facebook.com (173.252.90.36) 56(84) bytes of data. 64 bytes from... (5 Replies)
Discussion started by: 5sku5
5 Replies

10. UNIX for Beginners Questions & Answers

Shell script for continuously monitoring log file

Hi I have written below log monitoring script to egrep multiple words and redirect the output to a text file and its working fine but I want to add some more below given functionality to it, which is very advance and im not very good in it, so please help if you can :) I am egrepping all the... (1 Reply)
Discussion started by: scazed
1 Replies
WIKI-TOOLKIT-REVERT-TO-DATE(1p) 			User Contributed Perl Documentation			   WIKI-TOOLKIT-REVERT-TO-DATE(1p)

NAME
wiki-toolkit-revert-to-date - Revert the state of a Wiki::Toolkit instance to an earlier point in time. SYNOPSIS
# Removes any changes made to a Wiki::Toolkit instance since a given date # (and optionally time), restoring it to the state at that point. wiki-toolkit-revert-to-date --type postgres --name mywiki --user wiki --pass wiki --host 'db.example.com' --port 1234 --date 2007-01-05 --time 11:23:21 DESCRIPTION
Takes three mandatory arguments: type The database type. Should be one of 'postgres', 'mysql' and 'sqlite'. name The database name. date The date to revert the state back to, in the format YYYY-MM-DD five optional arguments: time The time (on the specified date) to revert the state back to, in the format hh:mm:ss. If not specified, will use midnight. user The user that connects to the database. It must have permission to create and drop tables in the database. pass The user's database password. host The hostname of the machine the database server is running on (omit for local databases). port The port number that the database server is expecting connections to. AUTHOR
Nick Burch COPYRIGHT
Copyright (C) 2006 Nick Burch. All Rights Reserved. This code is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Wiki::Toolkit perl v5.14.2 2011-09-25 WIKI-TOOLKIT-REVERT-TO-DATE(1p)
All times are GMT -4. The time now is 04:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy