How to deal with unplug from the LAN
Alex Tweedly
alex at tweedly.net
Wed May 26 19:52:51 EDT 2010
Hmmm ... looks like you may have a problem with copy/paste in creating
this email. in "connectionStatus" the first if ...then...else cluae will
*always* cause a return, so the check for Airport never gets used. I
suspect the original code did the Airport check first, then the Ethernet
one - that would have been OK.
In general, can there not be more than one ethernet interface installed
- so why not check if *any* interface of the form"enx" ihas status active.
e.g. (typed direct into email - beware typos) ...
set the itemdel to ":"
repeat for each line L in tStatus
if char 1 to 2 of L = "en" & char 3 to -1 of (item 1 of L) is a
number then
put lineOffset (L,tStatus) into tTarget
put line ((lineOffset ("Status:",tStatus,tTarget))+tTarget) of
tStatus into tENstatus
if (item -1 of tENstatus) = " active" then
return "true"
end if
end repeat
return 'false'
-- Alex.
On 26/05/2010 18:16, Web Admin Himalayan Academy wrote:
> With a tip from Andre, we solved this problem... it's really pretty
> neat. Perhaps someone else may need this.
>
> Mac Only
>
> This queries the hardware-network interface and give you and instant
> response... if the users just unplugs from the network or turns of her
> airport, with a remote volume mounted... you want to be sure you don't
> try to interact with the server...otherwise you will get a 2 minute
> time out waiting before the system gives back the CPU to RunRev....
>
> Do this first: (disclaimer, any code I offer probably could be highly
> optimized)
>
> function connectionStatus
>
> put shell("ifconfig") into tStatus
>
> # Parse for ethernet status
> put lineOffset ("en0:",tStatus) into tTarget
> put line ((lineOffset ("Status:",tStatus,tTarget))+tTarget) of
> tStatus into tEN0status
> set the itemdel to ":"
> if (item -1 of tEN0status) = " active" then
> return "true"
> else
> return "false"
> end if
>
> # Check Airport-Wireless status
> put lineOffset ("en1:",tStatus) into tTarget
> put line ((lineOffset ("Status",tStatus,tTarget))+tTarget) of
> tStatus into tEN1status
> set the itemdel to ":"
> if item -1of tEN1status = " active" then
> return "true"
> end if
> end connectionstatus
>
> Then all other places you need to interact with the server:
>
> command CheckVarunaIsMounted
> if connectionStatus() <> "True" then
> answer "You appear to be offline line. Connect to the network by
> ethernet or airport. Then try again." with "OK"
> exit to top
> else
> put URL
> "file:/Volumes/Varuna/WWW/*Sites/varuna.hindu.org/ping.txt" into
> gControlFile
> if gControlFile = "true" then
> set the icon of btn "Connected" to 1097
> put "true" into gVarunaMounted
> set the uVarunaMounted of this stack to "true"
> else
> put "false" into gVarunaMounted
> set the uVarunaMounted of this stack to "False"
> set the icon of btn "Connected" to 1098
> answer "Varuna is not mounted. Shall I mount it for you?"
> with "OK"
> mountVaruna
> exit to top
> end if
> end if
>
> end CheckVarunaIsMounted
>
> command Checkin pFileName
>
> CheckVarunaIsMounted
>
> if the uVarunaMounted of this stack <> "true" then
> answer "Sorry, Varuna is not mounted, you cannot check in
> files." with "OK"
> exit to top
> end if
>
> # increment revision number; change co to CI; retain user initials;
> rename local file
> put pFileName into tNewFileName
>
> etc...
>
> end checkIn
>
> Then I always run this every time I set the default folder to the
> server, when done getting the file listing:
>
> command unTetherStackFromServer
> set the defaultFolder to ($Home&"/Documents/")
> end unTetherStackFromServer
>
> and then the user gets no msg saying he can't unmount the volume
> because it is in use by RunRev.
>
> HTH somebody...
>
>
> Sivakatirswami
>
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list