MelJ Posted April 21, 2008 Posted April 21, 2008 I'm writing a small script to take my users to a website. The "Open URL" script step is a cakewalk. But I'm looking for a way to test if the user has a "Live" connection before I send them to their destination. This way if the user happens to have dial up I can inform them that they need to go online before they can continue. Any Ideas? Thanks, Mel
normanicus Posted April 22, 2008 Posted April 22, 2008 I had to mess around a bit to do this. You appear to be on Windows so I used vbscript: 1. Make a vbscript that pings a known IP address that is sure to be outside a local network. I use one of the OpenDNS addresses for this. This script is copied from here: http://www.connectingdata.com/downloads.htm in the file: VBscripts_repository_v1_0.zip It is found in Category: Hardware, Category 2: Monitoring. Here is (adapted) the vbscript: strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!" & strComputer & "rootcimv2") Set colPingedComputers = objWMIService.ExecQuery _ ("Select * from Win32_PingStatus Where Address = '208.67.222.222'") For Each objComputer in colPingedComputers If objComputer.StatusCode = 0 Then Wscript.Echo "Remote computer responded." Else Wscript.Echo "Remote computer did not respond." End If Next Just paste that into a file and call it testnet.vbs I hope this is OK with Wim Decorte! 2. Create a Filemaker script as below (I called it pingit): Set Variable [ $$Path; Value:"filewin:" & Get ( DesktopPath ) & "testnet.vbs" ] Send Event [ open document/application; File Name: “$$Path” ] [ Bring application to foreground ] The FM script is set to find the vbscript on the desktop. You can change this to where you place yours. Running the script produces a pop-up window outside FM that reports on the availability. Better would be to get a return value into Filemaker. I might try that, Norman
gregincolumbus Posted June 1, 2008 Posted June 1, 2008 Does anyone know a cross platform way to test for a live internet connection while running FMP9? I would like to kill a script if there is not a connection, but I have not found anything that works on both platforms Thanks
LelandLong Posted June 2, 2008 Posted June 2, 2008 Yes, load a common, almost always available webpage (google, fmforums, etc) in a webviewer. If the user doesn't need to see it make it 1 pixel tall. Use GetLayoutObjectAttribute in a calc to pull the html source data. Create a script loop that will find PatternCount ( [theHTMLsource] ; "
gregincolumbus Posted June 2, 2008 Posted June 2, 2008 Leland Thank you! I will give this a try. It sounds like the perfect solution. It would be nice if there was a Filemaker error code on the web viewer that indicates no connection (it displays a message of "no internet connection") to make this a bit easier, but your solution sounds great! Thanks again.....Greg
gregincolumbus Posted June 2, 2008 Posted June 2, 2008 This solution works perfectly. I created a blank html page on my website, created a layout with a webviewer that looked to that page..... added a 3 second pause to allow time for the page to load... then scraped the data from the web page and loaded to a local variable.....I then checked the contents of this variable. If it is not empty, then there is an active internet connection. Thanks for the help!
LelandLong Posted June 4, 2008 Posted June 4, 2008 Actually, the way you phrased it may be wrong... Test it. Run your test on a machine that has the ethernet cable unplugged, or aircard off, or whatever to guarantee no internet. Now run your test. Reason I say this, with no internet connection the webviewer may still load an error page. If so, your variable may still not be empty. Instead of a blank page, maybe have a success message that you can look for...
Recommended Posts
This topic is 6017 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now