I think you’ll need to employ Apple’s new GUI scripting commands in order to achieve this. (via AppleScript atleast. I don’t know of a Unix alternative.)
The code below toggles the internet sharing state. You should be able to get all you need from this:
tell application "System Preferences"
activate
end tell
tell application "System Events"
tell process "System Preferences"
click menu item "Sharing" of menu "View" of menu bar 1
tell window "Sharing"
tell tab group 1
click radio button "Internet"
if (exists button "Stop") then
click button "Stop"
else if (exists button "Start") then
click button "Start"
end if
end tell
end tell
end tell
end tell
good old routing isn’t too tough in Unix. Really, you have to run the following commands to get it running in the terminal (run them in sudo or as root):
natd -interface xxx
the xxx is the interface you want to share (en0 for enet, en1 for airport, ppp0 for modem)
then run
/sbin/ipfw -f flush
/sbin/ipfw add divert natd all from any to any via xxx
/sbin/ipfw add pass all from any to any
again, xxx is the same interface as from above.
If you need more help with it, go into a terminal and type “man natd”
:rolleyes: Hmmm… Not quite there. The applescript above doesn’t seem to completely run. In fact it doesn’t select the internet tab. It seems like a timing problem as the script will work if you manually open the sharing pane and then run the script. If you run the script with system prefs closed, it turns off file sharing. Any thoughts? I really want internet sharing to start on system startup.
yeah, i tried for hours yesterday sticking in delays here and there and varying the times, but no success…finally i just put it in a script folder and gave up.
Hey, what about a startup script that will run the scripts in a script folder…hmmmm…that would definatley work (a work around atleast!)