[windows2000] Re: Multiple arguments in a batch

  • From: Aaron Dokey <adokey@xxxxxxxxxxxx>
  • To: "'windows2000@xxxxxxxxxxxxx'" <windows2000@xxxxxxxxxxxxx>
  • Date: Tue, 10 Sep 2002 16:07:17 -0400

Ray,

Here is a bit of perl to get done what you want...  If you don't have perl
installed snag it from www.activestate.com, then just put this stuff into a
text file called something like cmdping.pl

Usage: cmdping.pl HOST CMD-ALIVE CMD-DEAD

Obviously it'll execute whatever you specify for CMD-ALIVE if the host is
alive and CMD-DEAD when it's dead. 

Useful?
-Aaron

#--BEGIN CODE--
use Net::Ping;
my ($host, $cmd_alive, $cmd_dead) = @ARGV;
my $p = Net::Ping->new("icmp") || die "Can't create object: $!\n";
if ($p->ping("$host")) {
        print "$host is alive\n";
        if ($cmd_alive) { system("$cmd_alive") };
} else {
        print "$host is dead\n";
        if ($cmd_dead) { system("$cmd_dead") }
}
#--END CODE--


-----------------------
Aaron Dokey - MIS
Reid Tool Supply
2265 Black Creek Rd.
Muskegon, MI   49444 
(231) 777-3951
(231) 767-3772 (Direct)
-----------------------

-----Original Message-----
From: Costanzo, Ray [mailto:rcostanzo@xxxxxxxxxxx]
Sent: Tuesday, September 10, 2002 3:41 PM
To: 'windows2000@xxxxxxxxxxxxx'
Subject: [windows2000] Re: Multiple arguments in a batch



Hi Jonathan,

This almost works.  Like, if the name can't be resolved, I'll get a false
return, but if the name is resolved but the response times out, I'll get a
true returned where I'm looking for a false.  I'll probably just suck it up
and pipe the output to a file.  This is only so that I can have my home
server ping my website while I'm at work and e-mail me if there's a problem.

Thanks,

Ray at work

> -----Original Message-----
> From: Jonathan Chan [mailto:jchan@xxxxxxxxxxxxx] 
> 
> 
> 
> At 08:06 AM 9/10/2002, you wrote:
> >I do know VB Script.  I just didn't know of any way to ping 
> an IP address or
> >get a shell response back to my script.  Like "strReturn =
> >objShell.Run("cmd.exe /c ping -n 1 domain.com") but it 
> doesn't really work
> >that way...  The only other thing I could think to do is 
> pipe the ping
> >results to a text file and read it with the file scripting 
> object then.
> >Doesn't matter really.  Thanks.
> >
> >Ray at work
> 
> 
> 
> try this:
> 
> Dim shell
> Set shell = CreateObject("WScript.Shell")
> 
> strReturn = Shell.Run("ping jchan", 1, true)
> 'msgbox strReturn
> 
> if strReturn = false then
>     do whatnot
> endif
> 
> 
> 


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


==================================
To Unsubscribe, set digest or vacation
mode or view archives use the below link.

http://thethin.net/win2000list.cfm

==================================
To Unsubscribe, set digest or vacation
mode or view archives use the below link.

http://thethin.net/win2000list.cfm

Other related posts: