<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3331121862033722524</id><updated>2011-07-07T21:47:41.292-07:00</updated><category term='AFP'/><category term='Who Is Connected'/><category term='SSH'/><category term='netstat'/><category term='cut'/><category term='grep'/><title type='text'>LittleMacApps.com</title><subtitle type='html'>Who Is Connected? Monitoring SSH &amp;amp; AFP Status Max OS X</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://littlemacapps.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3331121862033722524/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://littlemacapps.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>CJ</name><uri>http://www.blogger.com/profile/13034447370908453047</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_P0Z4-TE-p3s/Sie6G6wFagI/AAAAAAAAAAM/F1END7M_uCU/S220/portrait.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3331121862033722524.post-2761160182262565851</id><published>2009-06-15T05:51:00.000-07:00</published><updated>2009-06-15T14:45:22.642-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Who Is Connected'/><category scheme='http://www.blogger.com/atom/ns#' term='AFP'/><category scheme='http://www.blogger.com/atom/ns#' term='cut'/><category scheme='http://www.blogger.com/atom/ns#' term='grep'/><category scheme='http://www.blogger.com/atom/ns#' term='SSH'/><category scheme='http://www.blogger.com/atom/ns#' term='netstat'/><title type='text'>Part 2: Monitoring SSH status in Mac OS X Terminal</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;&lt; &lt;a href="http://littlemacapps.blogspot.com/2009/06/monitoring-afp-and-ssh-status-in-mac-os.html"&gt;Part 1: Monitoring AFP Status in Mac OS X Terminal&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', -webkit-fantasy;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', -webkit-fantasy;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;At the end of the last post, I gave the following solution to see whether AFP is enabled via Terminal:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', -webkit-fantasy;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;a href="http://littlemacapps.blogspot.com/2009/06/monitoring-afp-and-ssh-status-in-mac-os.html"&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', fantasy;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51); font-style: italic; "&gt;netstat -naf inet6 | grep [*][.]548[\ ].*LIST&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:'lucida grande', -webkit-fantasy;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:'lucida grande', -webkit-fantasy;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;If the above command returns nil (or blank) then AFP is disabled.  If it returns a line similar to the below, then AFP is enabled:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:'lucida grande', -webkit-fantasy;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:'lucida grande', -webkit-fantasy;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;tcp6       0      0  *.548                  *.*                    LISTEN&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:'lucida grande', -webkit-fantasy;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;As always, there are a multitude of different ways to return similar information e.g. If we replace the &lt;i&gt;-f inet6&lt;/i&gt; option of netstat (which looks for address families using &lt;i&gt;inet6&lt;/i&gt;) with the -p option (-p stands for protocol), we can then ask netstat to list all TCP services e.g. the following does pretty much the same thing as above:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:'lucida grande', -webkit-fantasy;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:'lucida grande', -webkit-fantasy;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;i&gt;netstat -nap TCP | grep [*][.]548[\ ].*LIST&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:'lucida grande', -webkit-fantasy;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:'lucida grande', -webkit-fantasy;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;however, returns all TCP services on port 548 i.e. tcp4 and tcp6 entries in return:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:'lucida grande', -webkit-fantasy;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:'lucida grande', -webkit-fantasy;color:#333333;"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:small;"&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;tcp4       0      0  *.548                  *.*                    LISTEN&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;tcp6       0      0  *.548                  *.*                    LISTEN&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I'm going to use the -p option to delve once again into netstat, to view whether SSH (Remote Login) is enabled in the terminal or not. However, this time, instead of building something up from the basic building blocks, lets take a look at the final terminal command and break it down:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;netstat -nap TCP | cut -c 22-40 | grep -w [*][.]22[\ ]&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;If you've read the &lt;a href="http://littlemacapps.blogspot.com/2009/06/monitoring-afp-and-ssh-status-in-mac-os.html"&gt;previous post&lt;/a&gt; you should be able to see where I'm heading.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;First of all, we're using netstat to return a list of current network connections and statistics using the options (-a) all (-n) network addresses which use the TCP (-p) protocol.  That's pretty straight forward.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We're then piping ( | ) the output through &lt;i&gt;cut&lt;/i&gt; which allows us to only select a portion of each line using the -c option to specify the character positions we want returned.  &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Why are we doing this?  Well, we are only interested in ports running on our local machine, not on other servers. If we're not careful, netstat will return a result for this command based on a SSH service running on a foreign server rather than our own.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;e.g. Here's a sample output from netstat based on a connection to google along with the standard netstat column headings:&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new', -webkit-fantasy;"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', -webkit-fantasy;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Proto &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;Recv-Q &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;Send-Q &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;Local Address &lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;Foreign Address &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;tcp4 &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;0 &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;0    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;192.168.0.5.54400 &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;209.85.227.191.80 &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The example above is only a http (port 80) connection, however if I was connected via SSH, the foreign address in this case would be: 209.85.227.192.22 (port 22 being the standard SSH port).  If I issued the command without cut i.e.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;netstat -nap TCP | grep -w [*][.]22[\ ]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;I could return a result based on the foreign address connection instead of the local address.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;So in order to remove from the nestat output any reference to ports being used in the foreign address column we are using cut -c 22-40.  What we're essentially saying is, give me the result from netstat but only the characters 22-40 of each line.  e.g. If I issued this command: &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;i&gt;netstat -nap TCP | cut -c 22-40&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I just get a result of:&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Local Address      &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;192.168.0.5.54400 &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Instead of:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Proto Recv-Q Send-Q   Local Address        Foreign Address&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;tcp4       0      0   192.168.0.5.54400    209.85.227.191.80&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', fantasy;"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:small;"&gt;Ok, that now leaves us with the final grep command: &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', fantasy;"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51); font-style: italic; "&gt;grep -w [*][.]22[\ ]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', -webkit-fantasy;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', fantasy;"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51); font-style: italic; "&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); font-style: normal; "&gt;This time we're using the -w option which forces grep to return only the lines that contain an exact match. What we're looking for in the netstat output is a local address listening port of *.22 i.e. port 22 of localhost.  We need to enclose * and . in [ square braces ] to force grep to include them as part of the pattern as they otherwise have a special meaning for pattern matching in regular expressions.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', -webkit-fantasy;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', fantasy;"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51); font-style: italic; "&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); font-style: normal; "&gt;Usually, or rather, by default, SSH runs over port 22.  For security reasons and other, SSH is often run on a custom port, so you'll need to substitute 22 for your unique port number if you've changed the default setting in e.g. /etc/services depending on your set up.  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', -webkit-fantasy;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', -webkit-fantasy;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Finally, we want to force an exact pattern match of *.22 not *.223 or *.2202 etc... so we need to add a forced blank space at the end of the pattern using an escape character followed by a space and both surrounded by square brackets [\ ]  &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', -webkit-fantasy;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', -webkit-fantasy;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Put that all together:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', -webkit-fantasy;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', -webkit-fantasy;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51); font-style: italic; "&gt;netstat -nap TCP | cut -c 22-40 | grep -w [*][.]22[\ ]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', -webkit-fantasy;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', -webkit-fantasy;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;and hey presto:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', -webkit-fantasy;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', -webkit-fantasy;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;*.22              &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;*.22&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you get a result similar to the above, Remote Login (SSH) is enabled in System Prefs.  If you get nothing, it's disabled.  &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;(PS This is probably, not fool proof. E.g. if you're running SSH over port 443 and you've also got a https server running, you're going to run into problems monitoring which service is enabled. However, I imagine you're going to come across problems anyhow trying to run two different services over the same port before you're even faced with this problem? Comments please!)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Coming soon... monitoring to see if you have active connections&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'lucida grande', fantasy;"&gt;&lt;&lt; &lt;a href="http://littlemacapps.blogspot.com/2009/06/monitoring-afp-and-ssh-status-in-mac-os.html"&gt;Part 1: Monitoring AFP Status in Mac OS X Terminal&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3331121862033722524-2761160182262565851?l=littlemacapps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://littlemacapps.blogspot.com/feeds/2761160182262565851/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://littlemacapps.blogspot.com/2009/06/part-2-monitoring-ssh-status-in-mac-os.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3331121862033722524/posts/default/2761160182262565851'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3331121862033722524/posts/default/2761160182262565851'/><link rel='alternate' type='text/html' href='http://littlemacapps.blogspot.com/2009/06/part-2-monitoring-ssh-status-in-mac-os.html' title='Part 2: Monitoring SSH status in Mac OS X Terminal'/><author><name>CJ</name><uri>http://www.blogger.com/profile/13034447370908453047</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_P0Z4-TE-p3s/Sie6G6wFagI/AAAAAAAAAAM/F1END7M_uCU/S220/portrait.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3331121862033722524.post-7409259226729135158</id><published>2009-06-12T01:58:00.001-07:00</published><updated>2009-06-15T11:10:37.584-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Who Is Connected'/><category scheme='http://www.blogger.com/atom/ns#' term='AFP'/><category scheme='http://www.blogger.com/atom/ns#' term='grep'/><category scheme='http://www.blogger.com/atom/ns#' term='netstat'/><title type='text'>Part 1: Monitoring AFP Status in Mac OS X Terminal</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;div&gt;There's two freeware apps that might be useful to take a look at before we start:&lt;/div&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;ol&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;The first is &lt;/span&gt;&lt;/span&gt;&lt;a href="http://projects.tynsoe.org/en/geektool/index.php"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;GeekTool&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; which I've only come across recently. It's a great way to run multiple terminal commands which overlay on top of your desktop, which when you're playing around in unix is a useful way to monitor the output of various commands without continuously having to retype them.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;The second is &lt;/span&gt;&lt;/span&gt;&lt;a href="http://rixstep.com/4/0/clix/"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;CLIX&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; a useful 'teaching aid' for unix on Mac OS X.  I learnt some useful tail and cut commands from CLIX to get just the output from the terminal that I was looking for.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Ok, here we go... At it's essence, &lt;/span&gt;&lt;/span&gt;&lt;a href="http://littlemacapps.com/software/whoisconnected.html"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Who Is Connected?&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; was designed to monitor AFP and SSH connections in Mac OS X.  If all it did initially was to show whether or not AFP and SSH are enabled or not in the menu bar, I'd be happy : ) &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;So this is where I started. How could I achieve this via terminal? Let's take look at Apple File Sharing (AFP) first:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;AFP is short for AppleTalk Filing Protocol, a network sharing protocol used in an AppleTalk network.  So my starting point was the Apple GUI Network Utility for a unix command &lt;/span&gt;&lt;/span&gt;&lt;a href="http://www.osxfaq.com/man/1/netstat.ws"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Netstat&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;.  Network Utility resides in your Applications &gt; Utilities folder and you can click on Netstat in the tabs across the top.  Here you can find some pretty verbose information regarding your current network status. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Choosing the option: &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Display the state of all current socket connections&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; gives a long list of all local and foreign addresses, connections and port numbers.  You can return the same output by opening Terminal (Applications &gt; Utilities) and typing:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;netstat -a&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;The -a option shows the status of all sockets including those used by server processes i.e. afp.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;If you look down this list, and you have Apple File Sharing enabled in System Preferences, you'll notice that the output includes the lines:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Proto Recv-Q Send-Q  Local Address          Foreign Address&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', -webkit-fantasy;"&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;tcp4       0      0  *.afpovertcp           *.*                    LISTEN&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;tcp6       0      0  *.afpovert             *.*                    LISTEN&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Netstat is telling us that there is a server process LISTEN-ing for remote connections from any address (*.*) that want to connect to a service running on the local machine called &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;afpovertcp &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;f&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;p&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;-&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;o&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;v&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;e&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;r&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;-&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;c&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;p&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Disable Apple File Sharing in System Preferences and run Netstat again.  This line disappears i.e. the computer is no longer listening for incoming AFP connections. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Great! so netstat tells us whether or not AFP is enabled in System Preferences.  But I don't want to navigate through the verbose output of nestat each time to view this.  Fortunately, there are various unix commands to help us limit the output of netstat to just what we are looking for.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;First, we can limit the output of nestat and speed up it's response by limiting the results it returns to look at one particular address family, in this case we can use inet6:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;netstat -a -f inet6&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Try it! Secondly we can 'pipe' the output of netstat through &lt;/span&gt;&lt;/span&gt;&lt;a href="http://www.osxfaq.com/tutorials/learningcenter/unixtutorials/GrepSedRegexp/index.ws"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;grep&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; - to limit the output to the exact line that we are looking for:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;netstat -a -f inet6 | grep afpovert&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;This command firstly runs &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;netstat -a -f inet6&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; but only returns the lines which include the text &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;afpovert. &lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;i.e. grep is acting like a filter to return only the lines we are interested in. Here's the result:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;tcp6       0      0  *.afpovert             *.*                    LISTEN&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;However, the response time is still slower that what I'd like as netstat is still having to run a command to investigate all network connections on the inet6 family of addresses, before it returns its result subsequently filtered by grep.  If you're running Tiger, you'll see what I mean.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;If we look at the options of netstat:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;m&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;e&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;s&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; We find &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;we can add the -n option to only show us port numbers rather than an interpreted symbolic address i.e. if we know what port number AFP is running on, we can look for this in netstat's output, rather than asking netstat to do extra work of displaying the symbolic address of all connections&lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;. &lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; Fortunately, AFP consistently runs on port 548 so we can change our command to:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;netstat -naf inet6 | grep 548&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Great! an instant result:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;tcp6       0      0  *.548                  *.*                    LISTEN&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;S&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;o&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;i&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;f I run this command and it returns a result, then I know that AFP is enabled in my System Preferences. Or do I?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Actually, my grep command isn't sophisticated enough.  What if there is a different service running on port 5482? or 1548? or any combination of numbers which includes the pattern 548?  We will then return an incorrect result as to whether file sharing is enabled or not. We need to improve our grep filter to match exactly what we are looking for in netstat's result.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Lets first ensure we include the *. before the 548 so no numbers can preceed the actual port value we are looking for:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;netstat -naf inet6 | grep [*][.]548&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;As * and . are special characters as part of regular expressions, we need to surround them each with a [ square brace ].  Finally we want to ensure there is a blank space character after 548.  To do this, we need to use an escape character \ and a space surrounded by square braces to ensure we force grep to pattern match exactly the number we are looking for.  Our expression then becomes:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;netstat -naf inet6 | grep [*][.]548[\ ]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;For good measure, lets also ask grep to also only return results from netstat of connections which are actively listening for connections, as the AFP service should do:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;netstat -naf inet6 | grep [*][.]548[\ ].*LIST&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;The . after the square brace means 'concatenate' or add the next thing that comes to the query. The following * effectively means: any number of characters inbetween the end of the space character we've just looked for until the next pattern.  &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;LIST&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; is for LISTEN in order to remove pattern matching of other connections from the list e.g. ESTABLISHED etc...&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;So here we have our command for checking if AFP is enabled:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;netstat -naf inet6 | grep [*][.]548[\ ].*LIST&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;phew!&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;i&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', -webkit-fantasy;"&gt;&lt;i&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" font-style: normal;"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" font-style: normal;"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&gt;&gt; &lt;a href="http://littlemacapps.blogspot.com/2009/06/part-2-monitoring-ssh-status-in-mac-os.html"&gt;Part 2: Monitoring SSH status in Mac OS X Terminal&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/i&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3331121862033722524-7409259226729135158?l=littlemacapps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://littlemacapps.blogspot.com/feeds/7409259226729135158/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://littlemacapps.blogspot.com/2009/06/monitoring-afp-and-ssh-status-in-mac-os.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3331121862033722524/posts/default/7409259226729135158'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3331121862033722524/posts/default/7409259226729135158'/><link rel='alternate' type='text/html' href='http://littlemacapps.blogspot.com/2009/06/monitoring-afp-and-ssh-status-in-mac-os.html' title='Part 1: Monitoring AFP Status in Mac OS X Terminal'/><author><name>CJ</name><uri>http://www.blogger.com/profile/13034447370908453047</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_P0Z4-TE-p3s/Sie6G6wFagI/AAAAAAAAAAM/F1END7M_uCU/S220/portrait.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3331121862033722524.post-3748902618547149855</id><published>2009-06-09T15:12:00.000-07:00</published><updated>2009-06-15T13:05:04.053-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Who Is Connected'/><title type='text'>Preview: Who Is Connected?</title><content type='html'>&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Verdana"&gt;&lt;span class="Apple-style-span" style="  white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;Monitoring SSH &amp;amp; AFP Status for Mac OS X&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Verdana"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Verdana"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;span class="Apple-style-span"  style="  white-space: pre; font-size:11px;"&gt;&lt;/span&gt;I've always wanted to glance up into the menu bar and see the status of Apple File Sharing (AFP) and Remote Login (SSH) on my Mac.  Apple provide a whole range of menu bar (NSStatus) options for AirPort, bluetooth, sound, date, time, battery life etc... But not for file sharing.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Verdana"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Verdana"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;In fact, not only would I like to see what's happening in relation to File Sharing and SSH connections, I'd like to be notified of new connections.  Having to jump into System Preferences in order to view current sharing status and monitor netstat via terminal to review current connections, seems a little too labour intensive for such a simple request.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Verdana"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Verdana"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;After extensive Googling, I was surprised that I couldn't find any ready made solutions.  The best I could find was &lt;/span&gt;&lt;a href="http://en.sparrer-online.de/software/afpstatus/afpstatus.html"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;AFPStatus&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt; over at &lt;/span&gt;&lt;a href="http://en.sparrer-online.de/software/afpstatus/afpstatus.html"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;sparrer-online.de&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;, however, I wanted something with a smaller footprint, a simpler icon and additional functionality of monitoring incoming SSH connections. &lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Verdana"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Verdana"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;After playing around with AppleScript and the excellent &lt;/span&gt;&lt;a href="http://growl.info/"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;Growl&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt; notification framework, I quickly had a working version of a simple notification application which highlighted new incoming SSH connections. So how big would the step be to get this working as a true app for Mac OS X?&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Verdana"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;a href="http://littlemacapps.com/software/whoisconnected.html"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 80px; height: 67px; border:none;" src="http://littlemacapps.com/images/whoisconnected_logo.png" border="0" alt="" /&gt;&lt;/a&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Verdana"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;Having wanted to for a while, I had finally found an excuse to take the plunge and dive into Xcode.  So over the next few blogs, I'll run through my journey of creating Version 1.0 of &lt;/span&gt;&lt;a href="http://littlemacapps.com/software/whoisconnected.html"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;Who Is Connected?&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt; due for release June 09.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Verdana"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Verdana"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', fantasy;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Verdana"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', -webkit-fantasy;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Verdana"&gt;&lt;span class="Apple-style-span"  style="font-family:'lucida grande', -webkit-fantasy;"&gt;&lt;a href="http://littlemacapps.blogspot.com/2009/06/monitoring-afp-and-ssh-status-in-mac-os.html"&gt;&gt;&gt; Part 1: Monitoring AFP Status in Mac OS X Terminal&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Verdana"&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3331121862033722524-3748902618547149855?l=littlemacapps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://littlemacapps.blogspot.com/feeds/3748902618547149855/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://littlemacapps.blogspot.com/2009/06/who-is-connected-monitoring-ssh-afp.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3331121862033722524/posts/default/3748902618547149855'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3331121862033722524/posts/default/3748902618547149855'/><link rel='alternate' type='text/html' href='http://littlemacapps.blogspot.com/2009/06/who-is-connected-monitoring-ssh-afp.html' title='Preview: Who Is Connected?'/><author><name>CJ</name><uri>http://www.blogger.com/profile/13034447370908453047</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_P0Z4-TE-p3s/Sie6G6wFagI/AAAAAAAAAAM/F1END7M_uCU/S220/portrait.jpg'/></author><thr:total>1</thr:total></entry></feed>
