WeaponX
Aug 17 2007, 01:29 AM
| | I want a batch/dos file that will ping certain IP addresses at intervals of say 1 hour. If the IP address is not pingable after each hourly checkup, I want it to give some kind of warning. Maybe startup a notepad file and indicate the IP address that lost the network connection.
I will want to improve on this later on, but for now, a simple dos batch file or something similar will do.
I'm using Windows XP at the office network.
Thanks. |
Reply
develCuy
Aug 17 2007, 03:37 AM
hey!, maybe you have to install some Unix stuff in your Box. Try using cygwin, Unix batch is very very powerful. With a cron task and php, you will be able solve this "homework" easily. Anyway, if this is for a "live or death" request, try using some IP MonitorBlessings!
Reply
dserban
Aug 17 2007, 07:36 AM
Here is an example of how I would solve your problem using cygwin in my setup at home. 192.168.1.1 is the IP address of my wireless router, so it always responds to a ping. 192.168.1.2 is the IP address of my PC - the one I would run this script on. 192.168.1.3 is - let's say - the IP address of a PC that is currently off. I have cygwin installed and all the binaries are in C:\cygwin - this directory is in my PATH. These binaries I'm talking about are Win32 ports of POSIX utilities - very slick, very powerful tools that I strongly believe every serious IT professional should be familiar with. They make a very good team with the pre-existing Windows command line utilities, whether they be built-in ones, or resource kit ones, or whatever other command line based power tools you may have. As a prerequisite to the solution below, I have temporarily enabled the Messenger service on my 192.168.1.2 box - this one is required in order for the net send command to work. Before I start describing the solution, this is a little experiment I did - please note the use of the $? return code, which may be 0 for successful and 1 meaning failure.  What I did then is create a text file called ips.txt, like this:  and I ran the following script in the cygwin bash shell (remember this is still Windows XP, you're just pretending to work the way you would in UNIX): CODE while true do for ipaddress in `cat ips.txt` do ping $ipaddress if [ $? != 0 ] then net send 192.168.1.2 $ipaddress is down fi done sleep 3600 done and the popup that I get looks like this:  The net send command is not restricted to IP addresses, it can also recognize any kind of resolvable host name (NetBIOS, DNS, LDAP, etc...). If you want to get even fancier, you can put this on a server and configure it as a Windows background service using a small resource kit utility called srvinstw.exe. Good luck.
Reply
WeaponX
Aug 17 2007, 02:08 PM
Thanks for the replies guys. IP Monitor seems to only monitor the current computers IP Address. cygwin looks like the way to go. I will take a look at it. The only thing I don't like about doing it this way is that it requires the Messenger Service to be running. Is it possible to create if statements using dos commands also? I know my way around dos but when it comes to the if statements (if it applies to dos even), I'm at a loss. Maybe something like the code you have above? if 192.168.1.200 is down then open notepad and display that it's down .... Make it read a file and ping through all the IP addresses. If more than one IP Address is not able to be pinged, addend to the same notepad file indicating so. Thanks.
Reply
faulty.lee
Aug 17 2007, 03:10 PM
The dos batch file should look like this CODE ping 10.0.0.3 -n 1 > c:\ping.log IF %errorlevel% == 1 c:\windows\notepad.exe c:\ping.log -n 1 is to ping only once, cause if you ping more than once, standard is 4, it will take a long time to timeout. %errorlevel% is a dos variable and will be set by the last exited application, to determine if it pass or fail. ping will set %errorlevel% to 1 if it fail, and 0 if pass. So the IF statement will check the %errorlevel% variable, then run notepad if it fail. > c:\ping.log is to redirect the output of the ping to a text file. Using >> will append the output. ping.log must not exist, or else will be overwritten. For the hourly checking, you can use task scheduler, most windows will have one, including XP. You can schedule it to run the batch file every hour. It's under StartMenu\Programs\Accessories\System\Scheduled Task The hourly setting is a bit tricky. You have to set it to daily first, put a suitable starting time. If you pc is not turn on by then, it will only run the next day at that time. Then click Advance, check Repeat task, then you can select every hour. Duration you can put 10minute, or whichever time long enough for the ping to execute. You might want to experiment a bit, I'm not sure if after the duration, whether will it close the application that's launched by the batch file, in case if the ping fail. Good Luck
Reply
WeaponX
Aug 23 2007, 02:01 PM
Thanks faulty.lee. Is there any way to append to an existing log file as I don't want it to be overwritten? I will have a list of IP Addresses to ping and want to keep this log with all the messages (pass or failed). If I ping more than one IP Address, what code do I need to change or add in for this to work properly? I will set it to ping maybe 4 times for each IP address just to be sure it's still up. The batch file should go through all the IP addresses and if it finds an issue, then open up the notepad file.
Reply
dserban
Aug 23 2007, 02:30 PM
In order to append the output of a command to a file instead of overwriting the file you simply need to use the double greater than operator instead of a single greater than sign. I also think that, if you are going to do that, you may need timestamps before each command output. The native date command in Windows ("date /T" at the command prompt) only gives you the date and only in the format configured in your regional settings in control panel, but the date command in cygwin gives you both the date and the time and in a customizable format.
Reply
faulty.lee
Aug 23 2007, 04:09 PM
What dserban said is right. In fact i did mentioned in my previous post "Using >> will append the output". You just need to do multiple IF for each ping, and all ">>" append to the same output log file.
Reply
wutske
Aug 25 2007, 08:57 AM
Why using a batch file while there are plenty of tools on the internet available that can do all this things for you ?
Reply
faulty.lee
Aug 27 2007, 07:25 PM
QUOTE(wutske @ Aug 25 2007, 04:57 PM)  Why using a batch file while there are plenty of tools on the internet available that can do all this things for you ? Well, why trouble yourself with downloads from the internet, where you have to test and scan (spyware) each tools as you try them out. Also, batch file is the simplest of all scripts, guaranteed to works in all windows, regardless of what's installed or not. A fool prove, fast and get the job done method in this case. Also, as WeaponX's mentioned, it's temporary. So I reckon he want to get a right a program to do a better job later.
Reply
Recent Queries:--
ping from website script - 12.32 hr back. (1)
-
dos script to ping servers - 58.22 hr back. (1)
-
write script files to ping ip address - 85.46 hr back. (1)
-
"ping error level" - 99.12 hr back. (2)
-
web script network ping php - 196.47 hr back. (1)
-
free php script "change ip" - 234.27 hr back. (1)
-
ping bash script - 259.97 hr back. (2)
-
ping batch file - 261.69 hr back. (1)
-
batch script operator - 266.28 hr back. (1)
-
php ping monitor - 273.13 hr back. (4)
-
dos batch file to monitor ip address - 284.73 hr back. (1)
-
ping batch script - 382.61 hr back. (1)
-
ping batch file "ip address" - 382.70 hr back. (2)
-
ping script - 386.03 hr back. (1)
Similar Topics
Keywords : script, ping, monitor, network
- Looking For Script
need help (5)
Auto-click Script
(7) I wanna know how to make a "auto-click" script in web browser.... i want it to do this: I am on a
web page...I have 3 options to click....so i want it to click one,after it reloads it waits for 25
seconds and clicks 2nd,and again waits to reload and that 25 seconds and clicks 3rd option... is it
possible to create that kind of script?it would be better if it was executable program so u can set
it where exactly it should click... if you don't understand some of things i said tell me and i
will "translate" it into English XD....
I Need An Affilate Script ,any Suggestions?
(1) It is like i am selling a particular product,i need to promote it through an multilevel affiliate
program. can u suggest a good affilate script.....
How Can I Create A "number Of Visitors" Script
(8) Sorry, I am rather new on this forum, so I'm not quite sure it's the best place to ask this
question, maybe a moderator should move my post to a more accurate subforum. However, I really would
like to have this info. How can I add a counter in my page, counting the people visiting my webpage
? Is there a script "ready for use" somewhere on astahost ? Regards Yordan....
I Need A Re-direction Script
I need a script... (12) I'm looking for a re-direction script to re-direct you form one page to another automatically
within the space of a few seconds. Like say I type www.sitename.com I want the script to activate
straight away or within a few seconds to take them to like ww.sitename.com/file.php. I've
looked through good-tutorials, phpfreaks, kirupa, html-goodies, and I couldn't find a script.
can anyone help. HTML, PHP, JavaScripts are the kind I'm looking for, prefeably html or php.
Note: I didn't know where to post this seeing as I'm looking for one of three diff....
Looking for script, ping, monitor, network
|
*RANDOM STUFF*
*SIMILAR VIDEOS*
Searching Video's for script, ping, monitor, network
|
advertisement
|
|