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

karde

macrumors newbie
Original poster
Apr 26, 2014
8
0
Hi!

I have successfully been running the script below, but with the latest OSX update, 10.9.2, the script hangs on first run when pressing "Yes", the Applescript program freeze but completes it's task... if I force quit the application and rerun the applescript, it quits (works as intended) every time no mather the chooice, I have saved the application as a program.

Sorry, I ain't any good at Applescript, so forgive me if I have done some obvious thing that is messed up, but it has worked flawlessly before..

here's my script:

Code:
[B][I]display dialog "Share internet connection?" buttons {"Yes", "No"}

set the button_pressed to the button returned of the result
if the button_pressed is "Yes" then
	do shell script "/Users/Karde/Desktop/Shareinternet.sh" user name "root" password "*****" with administrator privileges
	
else if the button_pressed is "No" then
	do shell script "/Users/Karde/Desktop/Stopshare.sh" user name "root" password "*****" with administrator privileges
	
end if[/I][/B]

Thanks for any help!!
 
Last edited by a moderator:

Partron22

macrumors 68030
Apr 13, 2011
2,655
808
Yes
It surprises me you need root to do this, or a UNIX executable for that matter. Have you look for other options in the last couple years?
What with sandboxing and App permissions now set on an App by App basis in Security and Privacy prefs, I'm not too suprised your script isn't working.
Best bet is likely to find new software to do the toggle for you.
 

karde

macrumors newbie
Original poster
Apr 26, 2014
8
0
Ok, thanks, sorry, but why shouldn't the script be working? Im calling for a .sh file which set's the ipforwarding to value 1 for my tap interface, the script helps me to easy share my internet connection. It's still working, just that it hangs on first run.. I mean, shouldn't I have more problems than just this if it was totally wrong?
Could you please explain what you mean with:
"What with sandboxing and App permissions now set on an App by App basis in Security and Privacy prefs, I'm not too suprised your script isn't working."?


Sorry, like I said, I might not grasp the concept around this, but I would like to understand :).


This is my Shareinternet.sh file:

Code:
#!/bin/sh
natd -interface tap0
ipfw -f flush
ipfw add divert natd ip from any to any via tap0
ipfw add pass all from any to any
sysctl -w net.inet.ip.forwarding=1
 
Last edited by a moderator:

Partron22

macrumors 68030
Apr 13, 2011
2,655
808
Yes
It's still working, just that it hangs on first run..
Oh, I misunderstood.

The first time you run it, it may be taking longer than applescript likes to bring up the network connection. There's several things you could try to get around that.
Let X = your script as it is

Code:
ignoring application responses
X
end ignoring
Code:
try
X
end try
Code:
with timeout of 300 seconds
X
end timeout

I'd test them in the order they're listed.
First one should return control to your applescript before the .sh even finishes running.
Second one'll just give up if an error occurs.
Third one'll give the .sh 5 minutes to finish running.

Mavericks, Applescript, security and sandboxing.
 

karde

macrumors newbie
Original poster
Apr 26, 2014
8
0
Thanks, but still no luck :/

Was it correct to put these commands like this:
Code:
[I]set the button_pressed to the button returned of the result
if the button_pressed is "Yes" then
[B]with timeout of 300 seconds[/B]
	do shell script "/Users/Karde/Desktop/Shareinternet.sh" user name "root" 
password "*****" with administrator privileges
[B]end timeout[/B]	
else if the button_pressed is "No" then...
[/I]
 
Last edited by a moderator:

karde

macrumors newbie
Original poster
Apr 26, 2014
8
0
Ok, thanks for your help anyway!! Thanks for taking your time!! If anyone else had any suggestions what can be wrong I'd truly appreciate it!! :)
 

duramo

macrumors newbie
Jul 26, 2012
8
0
I think it is fixed on 10.9.3, so please update your system. I had exactly this issue, but after updated my system to 10.9.3, the problem is gone. :cool:
 

karde

macrumors newbie
Original poster
Apr 26, 2014
8
0
Wow, thanks!! It now works again :)! 10.9.3 did the trick!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.