Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

do is not doing it!

by cybear (Monk)
on Apr 12, 2002 at 12:23 UTC ( [id://158551]=perlquestion: print w/replies, xml ) Need Help??

cybear has asked for the wisdom of the Perl Monks concerning the following question:

Wisdom Holders,
I have a script, GET.pl, among others, that connects to machines outside of my firewall to retrieve data. Before I initiate that connection I call an external script, pingtest.pl, that determines which of my firewalls can connect to that external server. When a connection failure occures the pingtest.pl script issues an e-mail alert to my OPS team.

My problem is: I have no way of telling which script on which server has the failing pingtest.pl.

I am using my @values = do '/usr/local/bin/pingtest.pl'; to call the script. It returns info to the @values array but I cannot figure out how to pass the name of the calling script to the pingtest.pl script. my @values = do '/usr/local/bin/pingtest.pl myhostname'; does not work.

Please reveal the pearl of PERL of Wisdom that I do not possess.

Replies are listed 'Best First'.
Re: do is not doing it!
by tachyon (Chancellor) on Apr 12, 2002 at 12:30 UTC

    You can do it in several ways, backtics should work or you could use open - see IPC::Open3:

    $myhostname = 'some_host'; @values = `/usr/local/bin/pingtest.pl $myhostname`;

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      Thank you. I for some reason I didn't think of that.

      Wisdom humbily received. :-)

Re: do is not doing it!
by broquaint (Abbot) on Apr 12, 2002 at 12:35 UTC
    Perhaps you want to use the backtick operator instead of do, as do will evaluate /usr/local/bin/pingtest.pl not execute it (similar but not the same). So you'll probably want something like this
    my @values = `/usr/local/bin/pingtest.pl`; chomp @values; # get rid of tricky newlines

    HTH

    broquaint

      My thanks to you. K - I - S - S, right?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://158551]
Approved by broquaint
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-19 16:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found