I am writing a program. This is what I think it should do:
Open, clobber and write a file called PING.TXT
ping a site until it can't anymore then email me
Here's what I have so far:
#! /usr/bin/perl -w
use strict ;
use Mail::Sendmail;
use diagnostics ;
open (PING, '+> C:\PING\PING.TXT') or die "Can't create file; $!" ;
# intentionally clobbering file
my $pingstat = 0 ;
my $ping = `ping -t 132.163.4.101` ;
until ($pingstat) {
$ping ;
} else {
$pingstat = 1 ;
} my %mail = ( To => 'lmoran@wtsg.com',
From => 'ellem@opt_online.net',
Subject =>"The PING is dead!",
Message =>"Go read your PING log"
);
format PING =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ping
.
I have all manner of fancy plans after I get this working but the until loop seems to be wrong. I have compared it to the ones I have written before and to the explanation in the Camel (PP3 pp. 112-116) and I have noticed that I have no if statement but I don't know what I would put in an if statement anyway. (That makes me a pretty poor programmer doesn't it?) I say this becuase I want to say:
ping this until you can't, else change the value of the variable $pingstat to 1 and email me to go read my logs.
--
lmoran@wtsg.com
There's more than one way to do it, just don't use my way.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.