Applescript freeze on first run - OSX 10.9.2

Discussion in 'Mac Programming' started by karde, Apr 26, 2014.

  1. karde, Apr 26, 2014
    Last edited by a moderator: Apr 26, 2014

    karde macrumors newbie

    Joined:
    Apr 26, 2014
    #1
    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!!
     
  2. Partron22 macrumors 68000

    Partron22

    Joined:
    Apr 13, 2011
    Location:
    Yes
    #2
    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.
     
  3. karde, Apr 27, 2014
    Last edited by a moderator: Apr 28, 2014

    karde thread starter macrumors newbie

    Joined:
    Apr 26, 2014
    #3
    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
     
  4. Partron22 macrumors 68000

    Partron22

    Joined:
    Apr 13, 2011
    Location:
    Yes
    #4
    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.
     
  5. karde, Apr 28, 2014
    Last edited by a moderator: Apr 28, 2014

    karde thread starter macrumors newbie

    Joined:
    Apr 26, 2014
    #5
    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]
     
  6. Partron22 macrumors 68000

    Partron22

    Joined:
    Apr 13, 2011
    Location:
    Yes
  7. karde thread starter macrumors newbie

    Joined:
    Apr 26, 2014
    #7
    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!! :)
     
  8. duramo macrumors newbie

    Joined:
    Jul 26, 2012
    #8
    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:
     
  9. karde thread starter macrumors newbie

    Joined:
    Apr 26, 2014
    #9
    Wow, thanks!! It now works again :)! 10.9.3 did the trick!
     

Share This Page