I'm using combined perl and Expect scripts to do the following:

1. ping a host using expect (for technical reasons, I've had better luck
using expect than perl here)
2. for each system that responds to ping, perform a series of rsh commands
via perl

The expect script is this, where $hosts is a list of potential names to
ping:

        foreach h $hosts {
                spawn ping $h

                expect {
                        icmp_seq {
                                puts $h
                                exit 0
                        }
                }
        }

        puts ""
        exit -1

Calling the expect script looks like this, where $sName is the system name:

        my $sPing = `./ping.exp $sName`;

Later on, I check the results like this:

               if ($sPing ne '') {
                        print "$sPing is up";
                                [rsh commands]
               } else {
                        print "$sName is down";
               }

When I run this from a terminal window, it returns the pinged name and
everything works fine. However, I need it automated, so I set up a cron job.
The cron job never pings the hosts successfully--everything returns as
"down." My hunch is that it has to do with using "puts" in Expect and
backtick in perl--do they need a STDOUT stream to work properly? How can I
set this up to ping properly while automated?

Matthew

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to