Ping from Access Database

  • Thread starter Thread starter cyates
  • Start date Start date
C

cyates

Guest
I keep a large database with IP addresses and hostnames. Does anyone know how to initiate a ping and store the results?
 
I was hoping that you could use:

Shell "Ping 1.0.0.1 >pingtext.txt"

to run the ping command and pipe the output to a text file. (you could then read this in and parse it for the png results)

But I can't get it to work, it says 'bad parameter' and

Shell "Ping 1.0.0.1>pingtext.txt"
(without the space)
says 'unable to locate host 1.0.0.1>pingtext.txt'

It is possible to do this with RunApp in a macro, but then you can't insert a variable as the IP address...

... so I suppose you would have to do it the 'proper' way, which would be to use an activex control, this link should find you a few examples: http://download.cnet.com/downloads/1,10150,0-10001-103-0-1-7,00.html?tag=srch&qt=ping+control&cn=&ca=10001

Mike

[This message has been edited by Mike Gurman (edited 01-12-2001).]
 
Thanks to Mike Gurman for originally helping me with this.

Calling the shell command should work, but I have had to play around with the syntax of the command. Try:

Call Shell(c:\WINNT\system32\cmd.exe /c ping 1.0.0.1 > c:\Mydir\Myfile.txt, vbhide)

Access will not necessarily wait for the DOS command to finish before it goes on its way, so you might try:

If Dir("c:\Mydir\Myfile.txt") <> "" Then Kill "c:\Mydir\Myfile.txt"
Call Shell(c:\WINNT\system32\cmd.exe /c ping 1.0.0.1 > c:\Mydir\Myfile.txt, vbhide)
While Dir("c:\Mydir\Myfile.txt") = ""
Wend
DoEvents

You will have to specify your own path to the windir folder - I get mine from the windir environment variable. I also like to write the temporary file to the TEMP directory - also gotten from the TEMP environment variable. This makes it easy to import into a table because I always know where the temporary text file is.

Note that I am working on Windows 2000 with Access 2000.

HTH

Jon

[This message has been edited by jal1219 (edited 01-15-2001).]
 
Mike and JAL,

Thanks!
I will see if I can get that to work.

Chris
 

Users who are viewing this thread

Back
Top Bottom