How to view active services via terminal e.g. status of AFP etc...

Hi : )

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

Posted on May 16, 2009 12:33 PM

Reply
5 replies

May 17, 2009 6:49 AM in response to cjcj

Actually, after further review, this method doesn't work as it only returns the last log entry for AFP status rather than the current status.

E.g. the last log entry could be AFP Control: AFP Error but if the computer is then restarted, AFP Control doesn't get logged in the system log on restart. Hence the egrep command still returns: AFP Error, when in fact AFP is actually enabled and running.

Hence back to my original question! anyone know a way to view if FileSharing is currently active via the terminal, even when there are no connected users other than:

netstat -a -f inet6 | grep afp

and looking for:

tcp6 0 0 *.afpovert . LISTEN

as the result??? Or is this a reliable method? i.e. if afpovert is present is that a hard and fast way of discovering filesharing is enabled?

Message was edited by: cjcj

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to view active services via terminal e.g. status of AFP etc...

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.