Ping Utility with wxPing
Keywords: wxPing
Question:
My boss is wanting me to put together a program that will open a DUN connection, ping two addresses, report a pass/fail type message, store the results in a text file, and hang up.. I figured I could use the dial up script as a starting point, but was having trouble with two things mainly..1. If it was possible to retrieve text from a DOS box in Win95..
2. What command in WinBatch sends output to a text file??
3. How do I change the timeout on wxPing?
Answer:
NB: For wxPing to work, the target computer MUST be running tcp/ip and its associated "small servers" i.e. the ping server.Below is a script I use to verify our servers. Just change the top two lines at first.
The internet extender has a wxPing function to do the pings.
- ipaddrs is a space delimited list of servers to check.
- ipwho is the "friendly" name for those servers.
The ping wait time is set to default to about 15 seconds.
The wxParmSet function may be used to set the ping timeout to a lower number.
To keep a log file...
data="stuff you want to write to the log" handle=FileOpen("C:\temp\log.txt","APPEND") FileWrite(handle,data) FileClose(handle)Now the main script:;===================================cut============================ ;ServerCheck.wbt ipaddrs="206.63.11.254 206.63.11.48 206.63.11.10 www.windowware.com 206.63.0.254" ipwho="Router Duality Commerce Winware Dilbert" IntControl(12,9,0,0,0) Addextender("wwwsk34I.dll") ipcount=ItemCount(ipaddrs," ") downlist="" count=0 BoxTitle("Initializing") while 1 count=count+1 good=0 For xx=1 to ipcount thisip=ItemExtract(xx,ipaddrs," ") thiswho=ItemExtract(xx,ipwho," ") a=wxPing(thisip) if a==0 ;Ooop TimeDelay(5) a=wxPing(thisip) ; try again if a==0 ;Ooop TimeDelay(5) a=wxPing(thisip) ; try again if a==0 ;Ooop TimeDelay(5) a=wxPing(thisip) ; try again endif endif endif b=ItemLocate(thiswho,downlist," ") if a==0 ; Add to downlist if b==0 downlist=strcat(downlist," ",thiswho) endif BoxOpen("DOWN %count%",downlist) mmpos=MouseInfo(2) mmx=ItemExtract(1,mmpos," ") mmy=ItemExtract(2,mmpos," ") MouseMove(0,0,"","") TimeDelay(0.25) MouseMove(10,10,"","") TimeDelay(0.25) MouseMove(mmx,mmy,"","") PlayWaveForm("C:\WINDOWS\MEDIA\AFFAIR.WAV",0) else good=good+1 ; Remove from if b!=0 downlist=ItemRemove(b,downlist," ") endif endif next if good==ipcount BoxShut() BoxText("All servers operational") BoxTitle("UP %count%") TimeDelay(30) else TimeDelay(5) endif endwhileSet the ping timeout with wxParmSet.
wxPing hanging when called from Powerbuilder
Question:
I have a PowerBuilder (PB) application that calls a winbatch program (exe - big compile) using the PB "run()" statement.The winbatch script sends a JCL file to the mainframe for execution using ftpQuote.
Everything works fine with a Windows NT 4.0 client but hangs (crashing the system) a Windows 95 client.
I've added a wxPing() call into the script before the ftpOpen() command. This doesn't seem to make any difference. However, I am finding that the script seems to work (more testing is needed) if I start the script with a Message() statement.
I'd like to know if anyone has any similar experiences and work arounds.
Answer:
Possibly some kind of timing issue.Maybe add:
TimeDelay(10)at the top of the script in place of the message, or some kind of message statement to the PowerBuilder code to see if making it wait for Winbatch to complete helps the situation.
wxPing hanging on Win95 950C machines - Workaround
There have been reports that wxPing fails on Win95 950C machines (but not 950B). A possible workaround to using wxPing is to use the DOS ping.exe command, as follows:runwait ("command.com", "/c ping.exe > ping.txt")and then you could do a file open on ping.txt to read the contents. So here's the general approach:E.g.:
- RunHide("command.bat","")
command.bat calls for "command.com"
- SendKeysTo("~MS-DOS","ping -w 2000 ipaddress > ping.txt")
- Delay(8)
- SendKeysTo("~MS-DOS","exit")
- The function to check if I got "Reply" in the file ping.txt.
- The result of the validation continues program or terminates the application.
; Test for connection to the server the first time, when connected, start the rest RunHide("command.bat", "") SendKeysTo("~MS-DOS", "del ping.txt{ENTER}") SendKeysTo("~MS-DOS", "Ping -w 1900 159.6.54.3 > ping.txt{ENTER}") Delay(10) SendKeysTo("~MS-DOS", "exit{ENTER}") Delay(2) fping = FileOpen("ping.txt","READ") strping = " " while @TRUE x = FileRead(fping) if x == "*EOF*" Then Break strping = StrCat (strping, x) endwhile FileClose(fping) pingok = StrIndex(strping, "Reply", 1, @FWDSCAN) If pingok!=0 then goto CONNECT
Article ID: W12690Filename: wxPing Utility.txt