How to view active services via terminal e.g. status of AFP etc...
How do I view whether AFP is enabled or not via the terminal?
I thought I could view /etc/hostconfig to get the answer when logged in via e.g. SSH. But in Leopard running the following terminal command:
cat /etc/hostconfig | grep "=\-" | sort
Always shows AFPSERVER as NO whether or not file sharing is turned on or not.
At the top of this file, it says #this file is going away. So I'm guessing there is another / better way to view this.
Hunting around a bit, I found that if I:
netstat -a
and filesharing is running, there are two entries *.afpovertcp and *.afpovert in the output.
tcp4 0 0 *.afpovertcp . LISTEN
tcp6 0 0 *.afpovert . LISTEN
Turning off filesharing removes these from netstat.
Doing the above command takes a few seconds to get a result as it seems to poll a whole range of different services and protocols, which as I'm calling this from a script I don't have time for, so if I:
netstat -a -f inet6 | grep afp
I get a near instantaneous result of:
tcp6 0 0 *.afpovert . LISTEN
if filesharing is turned on and null if it is turned off.
Can anyone point me in a different direction? Is there another way? Or is this as good as any?
Thanks...
Macbook [Black 2.4Ghz Core 2 Duo], Mac OS X (10.5.2), 4GB RAM