Checking for MySQL access

Terry Judd tsj at unimelb.edu.au
Sat Mar 14 18:01:29 EDT 2009


On 15/03/09 7:15 AM, "Devin Asay" <devin_asay at byu.edu> wrote:
 
> So this brings up a question. How could I check any given network to
> make sure that the appropriate ports is open BEFORE committing to
> attempting a MySQL connection, which seems to take about 2 minutes
> before it times out. I'm working on OS X, but would need a cross
> platform solution. Would some kind of netstat shell call give me the
> information I need?

Hi Devin - I found the script below in one of my projects. I¹m not sure how
useful it might be because it had been superseded with something much
simpler that simply checked for http access on the same server (which
wouldn¹t do what you want). Anyway, HTH.

Terry...

FUNCTION isOnline
    -- determines whether the mySQL database is online
    put seconds() into tElapsed
    set the sockettimeoutinterval to 2000
    put 3 into $MYSQL_CLIENT_TIMEOUT
    put "SELECT * FROM tbl_resources WHERE resource_id ="&quote&1&quote into
tSQL
    put 
revOpenDatabase("MySQL",[[dbLocation]],[[dbName]],[[userName]],[[userPass]])
into tID
    breakpoint
    IF tID = "" THEN return false
    IF tID contains "Can't connect" THEN
        return false
    END IF
    get revDataFromQuery(tab,return,tID,tSQL)
    revCloseDatabase tID
    return true
END isOnline



More information about the use-livecode mailing list