Opening port in System Preferences

I like to make a script that would open port 22 (Remote Login) in System Preferences/Sharing

I have found the following:

do shell script “/usr/bin/open /System/Library/PreferencePanes/SharingPref.prefPane”
activate application “System Preferences”
tell application “System Events”
tell process “System Preferences”
click checkbox 1 of row 4 of table 1 of scroll area 1 of tab group 1 of window “Sharing”
end tell
end tell

but this hangs on the line

click checkbox 1 of row 4 of table 1 of scroll area 1 of tab group 1 of

I get error

System Events got an error: NSReceiverEvaluationScriptError: 4

So now I am stuck. Any suggestions?

I am on OS10.4 BTW in case it matters.

Thanking you in advance

Hi,

your script works fine on my machine,
maybe “Enable access for assitive devices” is not checked in SysPrefs > Universal access

a workaround is


try
	do shell script "/sbin/service ssh start" password "¢¢¢¢¢" with administrator privileges
end try

it takes a while (here about 20 secs) and it throws an error but works anyway

If you run service --list in the terminal, you can see if it’s on – ssh will appear down near the bottom of the list. Doesn’t work as a do shell script for some reason.

Hi Adam,

I’ve tested this successfully on 10.4.11 PPC

try
	do shell script "/sbin/service ssh start" password "¢¢¢¢" with administrator privileges
end try

try
	do shell script "/sbin/service --test-if-configured-on ssh"
	say "on"
on error
	say "off"
end try

:rolleyes: I forgot “with administrator privileges” – doh!

Thanks, Stefan.

thanks folks for thinking with me, it works. I did not know I needed to turn “Enable access for assitive devices”

I works a dream can now program my server to turn the port on or of per email.

Now I thought having gotten this far I could figure out the rest. I can not.

I want to turn on a rule in the fire wall setting tab.

it is the 16th down the line and called “1254”

So I do not know how to open the “Firewall” tab, could you give an example of how to script this?

thanks