Windows Scripting
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsSystem AdministrationWindows Scripting

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old January 17th, 2007, 09:03 AM
Diggity Diggity is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 2 Diggity User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 37 m 22 sec
Reputation Power: 0
Question Newbie's ping script

Hi all - Self professed scripting newbie here. I'm trying to write a simple DOS script that will tell me very quickly which servers are up/down (after 3 power outages in one weekend, it would be nice to have a quick snapshot of what's up/down instead of waiting for our monitoring software to come up and start polling). Here's what I've got so far:

@echo off

FOR %%a in (server1,server2,server3) DO PING -w 1000 -n 1 %%a |find "TTL=" && ECHO %%a is alive

FOR %%a in (server1,server2,server3) DO PING -w 1000 -n 1 %%a |find "timed" && ECHO %%a Not Pingable!

FOR %%a in (server1,server2,server3) DO PING -w 1000 -n 1 %%a |find "check" && ECHO Cannot resolve IP address for %%a!

It actually works fine, but being the perfectionist that I am (yeah, right!), there are a few tweaks that I'd like to make, and I don't know how:

1) Have the script use a single list of servers, rather than having to specify server1,server2,server3 etc in each command. The list should NOT be an external file - I want to specify server names in the script to make it more easily portable, but I only want to specify them once.

2) Hide the ping output from standard out and only display the message specified. In other words, right now a successful ping will display this:

Reply from 192.168.1.10: bytes=32 time<1ms TTL=127
server1 is alive

I'd rather have it hide the reply and say only "server1 is alive." Sounds like a minor nit, but some of the people who will be using this script will be 1st level Help Desk folks, and they are easily confused. I don't want them to have to look at IP addresses and TTLs.

3) Leave the command window open after the script completes. Help Desk people may not remember to open cmd first and then run the script. If they double-click it in its current form, it will do its thing and then go away and they will think it didn't work.

Any help is appreciated!
Thanks!
-Diggity

Reply With Quote
  #2  
Old January 17th, 2007, 10:39 AM
mehere's Avatar
mehere mehere is offline
Senior Sarcasm Wizardess
Click here for more information.
 
Join Date: Feb 2005
Location: Dreamland
Posts: 12,867 mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 10976 Folding Title: Novice Folder
Time spent in forums: 4 Months 4 Weeks 15 h 20 m 54 sec
Reputation Power: 1762
not sure about the rest, but in order to keep the cmd window open, use 'pause' at the end, this will require them to hit a key to continue
Comments on this post
Diggity agrees: Thanks for the tip!
__________________
Come JOIN the party!!!

Quote of the Month:
Retirement: Because you've given so much of yourself to the company that you don't have anything left we can use.

Questions to Ponder:
What do you do when you see an endangered animal eating an endangered plant?

iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
copyright© 2008 sbenj69

Reply With Quote
  #3  
Old January 17th, 2007, 05:53 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181
Take a look around google, there are free downloadable server monitor programs that can alert you when a server goes off the air. Also network scanners are available, nmap on linux is very good and I see there is a windows version.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #4  
Old January 18th, 2007, 09:29 AM
Diggity Diggity is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 2 Diggity User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 37 m 22 sec
Reputation Power: 0
Quote:
Originally Posted by Doug G
Take a look around google, there are free downloadable server monitor programs that can alert you when a server goes off the air. Also network scanners are available, nmap on linux is very good and I see there is a windows version.


Thanks Doug, I've gone that route already. Tried BigBrother and FreePing. Both work great, as does our enterprise NMS, Microsoft Operations Manager. They don't exactly fit the bill though. I need a portable script that can be run by anyone in IT without having to check an NMS and will instantly give a snapshot of what's up/down.

The thing I neglected to mention is that the script will also echo out a series of "checklist" items for whomever is the first one to respond when the power comes back on. Stuff like:

echo Don't forget to check air conditioners in network closets!
echo Make sure hallway emergency lights are on in Building XYZ.
echo Log in to application X and make sure that blah blah blah.

Thanks!
-Diggity

Reply With Quote
  #5  
Old January 23rd, 2007, 02:30 PM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,048 Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Days 12 h 32 m 33 sec
Reputation Power: 555
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo
MySpace
You're beginning to get outside of the realm of NT scripting here. It's not designed to capture command output (from ping.exe)

Use WSH instead.
__________________
Click the image if at any point you don't like my decision.

Scripting problems? Windows questions? Ask the Windows Guru!


Reply With Quote
  #6  
Old January 24th, 2007, 09:03 AM
jgshdmgr jgshdmgr is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: Memphis, TN
Posts: 10 jgshdmgr User rank is Corporal (100 - 500 Reputation Level)jgshdmgr User rank is Corporal (100 - 500 Reputation Level)jgshdmgr User rank is Corporal (100 - 500 Reputation Level)jgshdmgr User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 h 10 m 58 sec
Reputation Power: 0
Send a message via AIM to jgshdmgr
i pieced together bits of script to allow me to ping a list of computer names that are in a spreadsheet. You could easily manipulate this code to have the server names hard-coded in there. And instead of moving to another cell to mark it as "Found" then you could have MSGBOX statements to echo the information you wanted.

Mine just verifies that it should be in AD. If it does not return a 172 in the address, it is "Not Found". Either way - this code can be altered to fit your needs easily enough.

Code:
Dim objshell, objWshScriptExec, objStdOut, strOutput
ActiveCell.Select
Do While ActiveCell > ""
Set objshell = CreateObject("WScript.Shell")
Set objWshScriptExec = objshell.Exec("ping " + ActiveCell + " -n 1")
Set objStdOut = objWshScriptExec.StdOut
'MsgBox strOutput
strOutput = objStdOut.ReadAll
Set objshell = Nothing
Set objWshScriptExec = Nothing
Set objStdOut = Nothing
Dim result
result = InStr(strOutput, "172.")
ActiveCell.Offset(0, 1).Select
	
	If result = 0 Then
		ActiveCell.Value = "Not Found"
	Else
		ActiveCell.Value = "Found"
	End If
	
ActiveCell.Offset(1, -1).Select
   
Loop
'MsgBox result

Reply With Quote
Reply

Viewing: ASP Free ForumsSystem AdministrationWindows Scripting > Newbie's ping script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT