Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

m4v3r1ck

macrumors 68030
Original poster
Nov 2, 2011
2,581
526
The Netherlands
Hi, found this 'solution?' on a forum for wifi loss in OSX LION 10.7.2.
Anybody here to tell me if this can be trusted?

Thanks in advance and Cheers!

"keepalive.sh"

#!/bin/bash
ping -i 5 -n yahoo.com
------------

"main.scpt"

set scriptName to "keepalive.sh" -- change this to what your script is called

set myPath to (path to me) as string
set myPath to posix_path(myPath)

do shell script "/bin/sh " & myPath & "Contents/Resources/Scripts/" & scriptName & " &> /dev/null"

on posix_path(mac_path)
set mac_path to (mac_path as text)
set root to (offset of ":" in mac_path)
set rootdisk to (characters 1 thru (root - 1) of mac_path)
tell application "Finder"
if (disk (rootdisk as string) is the startup disk) then
set unixpath to "/" & (characters (root + 1) thru end of mac_path)
else
set unixpath to "/Volumes:" & mac_path
end if
end tell
set chars to every character of unixpath
repeat with i from 2 to length of chars
if item i of chars as text is equal to "/" then
set item i of chars to ":"
else if item i of chars as text is equal to ":" then
set item i of chars to "/"
else if item i of chars as text is equal to "'" then
set item i of chars to "\\'"
else if item i of chars as text is equal to "\"" then
set item i of chars to "\\" & "\""
else if item i of chars as text is equal to "*" then
set item i of chars to "\\*"
else if item i of chars as text is equal to "?" then
set item i of chars to "\\?"
else if item i of chars as text is equal to " " then
set item i of chars to "\\ "
else if item i of chars as text is equal to "\\" then
set item i of chars to "\\\\"
end if
end repeat
return every item of chars as string
end posix_path
---------
 

jiminaus

macrumors 65816
Dec 16, 2010
1,449
1
Sydney
All the AppleScript main.scpt does in just starts keepalive.sh. Most of it a custom code to translate a path like Macintosh HD:Users:me into /Users/me. I don't why the posix path built into AppleScript wasn't used.

All keepalive.sh does is start a ping command to ping yahoo.com indefinitely every 5 seconds.

I guess the objective is not never let your wireless link be idle for more than 5 seconds.



AFAIK. main.scpt can be simplified to:
Code:
set scriptName to "keepalive.sh" -- change this to what your script is called

set myPath to path to me
set myPath to POSIX path of myPath

do shell script "/bin/sh " & myPath & "Contents/Resources/Scripts/" & scriptName & " &> /dev/null"
 

m4v3r1ck

macrumors 68030
Original poster
Nov 2, 2011
2,581
526
The Netherlands
Thnx!!!!!

All the AppleScript main.scpt does in just starts keepalive.sh. Most of it a custom code to translate a path like Macintosh HD:Users:me into /Users/me. I don't why the posix path built into AppleScript wasn't used.

All keepalive.sh does is start a ping command to ping yahoo.com indefinitely every 5 seconds.

I guess the objective is not never let your wireless link be idle for more than 5 seconds.



AFAIK. main.scpt can be simplified to:
Code:
set scriptName to "keepalive.sh" -- change this to what your script is called

set myPath to path to me
set myPath to POSIX path of myPath

do shell script "/bin/sh " & myPath & "Contents/Resources/Scripts/" & scriptName & " &> /dev/null"

Thanks a lot mate for your prompt reply! Not a programmer myself so I just wanted to check it with your guys....(and girls :p)

Cheers!!!!!
 

4np

macrumors 6502a
Feb 23, 2005
972
2
The Netherlands
Most of it a custom code to translate a path like Macintosh HD:Users:me into /Users/me. I don't why the posix path built into AppleScript wasn't used.

Just what I thought :p Typically something for the Daily WTF ;) In addition it does not even need to execute a shell script, it could have executed the ping requests itself as well... In fact, the script can even be a one-liner:

Code:
do shell script "screen -d -m ping -i 5 -n yahoo.com"

But on topic... This Applescript does nothing more than to send an ICMP request every 5 seconds to yahoo (via a strange setup from applescript to shell script). If your wifi is failing, your wifi setup is bad... You'd better go fix that instead of relying on a ping request to keep your wifi alive...
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.