comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Implementing Time-outs in IDL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Implementing Time-outs in IDL [message #7703] Sat, 04 January 1997 00:00 Go to previous message
Phil Williams is currently offline  Phil Williams
Messages: 78
Registered: April 1996
Member
Steve wrote:
> If the daemon server is off-line the spawn command hangs. Is there a way
> in IDL to cause a command to time-out? I would like my program to continue
> executing if the spawn command does not return a result in X seconds.
>
> Thanks, Steve

Why not first run spawn to ping the machine or check the active
processes for the daemon. Here's checkhost which will check to see if a
host is awake.

function checkhost, host, packets
; Uses spawn to ping host to check to see status. Tested w/ IRIX5.3
; results will need to be parsed differently on different systems.
; The results from ping -q -c packets host:
; PING www6.yahoo.com (204.71.177.71): 56 data bytes
;
;
; ----www6.yahoo.com PING Statistics----
; 10 packets transmitted, 10 packets received, 0% packet loss
; round-trip min/avg/max = 83/84/85 ms
;
; IDL> print,checkhost('www.yahoo.com')
; 1

on_error, 1
if n_elements(packets) eq 0 then packets = 10

;--- spawn a ping to check the host status
cmd = "ping -q -c " + strtrim(packets,2) + " " +host
spawn,["/bin/sh", "-c", cmd],/noshell,results

;--- Get info line for packets transmitted / received
which = strpos(results, 'packets')
found = where(which ne -1, count)
if count eq 0 then message, 'No ping info found for '+host
info = results(found(0))

;--- Now parse the info string
comma = strpos(info, ',')
transString = strmid(info,0,comma(0))

info = strmid(info,comma(0)+1,strlen(info))
comma = strpos(info, ',')
receivedString = strmid(info,0,comma(0))

percentString = strmid(info,comma(0)+1,strlen(info))

;--- Decide whether host is alive on the percent
p = strpos(percentString, '%')
percent = fix(strmid(percentString, 0, p))

if percent gt 10 then return, 0 else return, 1
end


--
/*********************************************************** ********/
Phil Williams, Ph.D.
Research Instructor
Children's Hospital Medical Center "One man gathers what
Imaging Research Center another man spills..."
3333 Burnet Ave. -The Grateful Dead
Cincinnati, OH 45229
email: williams@irc.chmcc.org
URL: http://scuttle.chmcc.org/~williams/
/*********************************************************** ********/
[Message index]
 
Read Message
Read Message
Previous Topic: CD-R Media for Sale
Next Topic: Implementing Time-outs in IDL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 10:35:29 PDT 2025

Total time taken to generate the page: 0.39959 seconds