<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Benjamin Sherman &#187; command line</title>
	<atom:link href="http://holyarmy.org/tag/command-line/feed/" rel="self" type="application/rss+xml" />
	<link>http://holyarmy.org</link>
	<description>I have to have a tagline?</description>
	<lastBuildDate>Wed, 02 Jun 2010 06:06:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Killing &#8220;find&#8221; Errors</title>
		<link>http://holyarmy.org/2009/11/killing-find-errors/</link>
		<comments>http://holyarmy.org/2009/11/killing-find-errors/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 05:46:53 +0000</pubDate>
		<dc:creator>benjamin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://holyarmy.org/?p=408</guid>
		<description><![CDATA[I&#8217;ve used the unix filesystem search utility find for many years. Though, like most things, until forced to learn its deeper secrets, I generally get by with only the most basic knowledge.
One of the cool things about find is that you can specify a search and then execute an action on the results, all in [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve used the unix filesystem search utility <strong>find</strong> for many years. Though, like most things, until forced to learn its deeper secrets, I generally get by with only the most basic knowledge.</p>
<p>One of the cool things about <strong>find</strong> is that you can specify a search and then execute an action on the results, all in one command.</p>
<p>This example is probably my most common use of <strong>find</strong>:</p>
<pre>find . -type d -name .svn -exec rm -fr {} \;
</pre>
<p>This means: find, in the current directory (.), a directory (-type d), named .svn (-name .svn), and for every result (-exec) remove that directory (rm -fr {}) .  The &#8220;{}&#8221; represents the matched path string, and the &#8220;\;&#8221; is required to end the &#8220;-exec&#8221; command.</p>
<p>Here&#8217;s a sample of what this looks like, including output:</p>
<pre>$ find . -type d -name .svn -exec rm -fr {} \;
find: ./.svn: No such file or directory
find: ./getid3-2.0.0b4/.svn: No such file or directory
find: ./getid3-2.0.0b4/extras/.svn: No such file or directory
find: ./getid3-2.0.0b4/getid3/.svn: No such file or directory</pre>
<p>This is great, and I&#8217;ve used this exact syntax for years. But today I ran into a problem. I wanted to run this exact command as part of a custom build script in Xcode. When this command ran I had <strong>81 errors </strong>popup in my build results! What happened is that all thos &#8220;No such file or directory&#8221; messages are actually errors, and Xcode reported them as such.</p>
<p>The solution is to add one extra argument: -depth . This causes find to do a depth-first traversal of the sub-directories being searched. That is, find will check the contents of directories before acting (eg, running an -exec command) on the directory in question. The default is to act on the directory (in our case, removing it) before attempting to visit it&#8217;s contents. So after we removed the directory, find was still trying to look at it; <strong>-depth </strong>fixes that.</p>
<p>So, the final answer is, I now use:</p>
<pre>find . -type d -name .svn -depth -exec rm -fr {} \;
</pre>
<p>Yes, this is a slightly verbose explanation for something so simple, but maybe it will help someone else.</p>
]]></content:encoded>
			<wfw:commentRss>http://holyarmy.org/2009/11/killing-find-errors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use vi key bindings in bash</title>
		<link>http://holyarmy.org/2008/12/use-vi-key-bindings-in-bash/</link>
		<comments>http://holyarmy.org/2008/12/use-vi-key-bindings-in-bash/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 06:29:38 +0000</pubDate>
		<dc:creator>benjamin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[geekery]]></category>

		<guid isPermaLink="false">http://holyarmy.org/?p=331</guid>
		<description><![CDATA[A long time ago I used ksh with vi key bindings, and life was good.
Then I moved on to bash, but for some reason, I never investigated using vi key bindings. I simply lived with the defaults (which, for the record, are emacs-like key bindings).
So, just the other day I said to myself, &#8220;Self, I [...]]]></description>
			<content:encoded><![CDATA[<p>A long time ago I used ksh with vi key bindings, and life was good.</p>
<p>Then I moved on to bash, but for some reason, I never investigated using vi key bindings. I simply lived with the defaults (which, for the record, are emacs-like key bindings).</p>
<p>So, just the other day I said to myself, &#8220;Self, I want to use vi key bindings in bash. I want to again experience the joy of traversing and editing my command line in COMMAND MODE. I want the speed and the power of my precious vi (well, I use vim) at my finger tips. And I NO LONGER want to waste time holding arrow keys or to think about using emacs-like commands.&#8221;</p>
<p>So, I fired up google.com; low and behold I stumbled onto this little post about <a href="http://blogs.techrepublic.com.com/opensource/?p=193">using vi key bindings in bash and zsh</a>. So sweet!</p>
<p>In a nutshell, the bash command to enable vi mode is:</p>
<p><code>set -o vi</code></p>
<p>This can be set in your .bashrc file, and if it doesn&#8217;t pickup when you start a new terminal session, add something like this to your .profile or .bash_profile:</p>
<p><code>if [ -f ~/.bashrc ]; then<br />
. ~/.bashrc<br />
fi</code></p>
<p>With vi mode enabled, you&#8217;ll start your bash session in insert mode, so things should behave as normal. But, to turn on the power, just hit the ESC key to enter COMMAND MODE. <img src='http://holyarmy.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Now all your vi commands are availble. Move to end of line with &#8220;$&#8221;, beginning of line with &#8220;^&#8221;, delete a word with &#8220;dw&#8221;, etc.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://holyarmy.org/2008/12/use-vi-key-bindings-in-bash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fight Back! (When VPN Clients Mis-Behave)</title>
		<link>http://holyarmy.org/2008/07/fight-back-when-vpn-clients-mis-behave/</link>
		<comments>http://holyarmy.org/2008/07/fight-back-when-vpn-clients-mis-behave/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 18:20:19 +0000</pubDate>
		<dc:creator>benjamin</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Networks]]></category>
		<category><![CDATA[cisco]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[mac hack]]></category>
		<category><![CDATA[scutil]]></category>
		<category><![CDATA[VPN]]></category>

		<guid isPermaLink="false">http://sherman.bz/?p=310</guid>
		<description><![CDATA[I have to use VPNs at work. Specifically, to access my production webservers (etc), I have to use a Cisco VPN client. Sadly, the VPN concentrator overrides my choice of allowing local LAN access. So, when I am on the VPN, I have my DNS options changed so I can&#8217;t use any local servers. This [...]]]></description>
			<content:encoded><![CDATA[<p>I have to use VPNs at work. Specifically, to access my production webservers (etc), I have to use a Cisco VPN client. Sadly, the VPN concentrator overrides my choice of allowing local LAN access. So, when I am on the VPN, I have my DNS options changed so I can&#8217;t use any local servers. This is a serious, serious pain. So painful in fact, that many times instead of fight with it, I simply would run a Windows session in VMware (on my Mac) and connect the VPN there. This has drawbacks too, but it&#8217;s better than not having local network access.</p>
<p>So I set out to find a solution and I found a <a href="http://blog.dv8.ro/2008/06/configuring-cisco-vpn-for-local-dns.html">post by loudhush</a> which described using the <strong>scutil</strong> to modify DNS network settings after connecting to a Cisco VPN. This was great, but I needed something a bit handier.</p>
<p>So, I cranked out the following which goes in my /Users/username/.profile:<br />
<code><br />
# .profile or .bash_profile<br />
function myvpn {<br />
vpnclient connect VPNPROFILENAME user MYVPNUSERNAME<br />
myworkdns<br />
}<br />
function myworkdns {<br />
printf "get State:/Network/Service/com.cisco.VPN/DNS\nd.add ServerAddresses * 192.168.1.252, 192.168.1.198\nd.add SearchDomains * example.com, other.example.com\nset State:/Network/Service/com.cisco.VPN/DNS" | sudo scutil<br />
}<br />
</code></p>
<p>These are bash functions which i run from the command line. (I also find the Client GUI Cisco to be a pain, and prefer command line)</p>
<p>So, obviously, you&#8217;ll need to substitute in your Cisco VPN profile name ( found in /etc/opt/cisco-vpnclient/Profiles), your VPN username, your DNS server IP addresses, and your DNS search domains to your legitimate values.</p>
<p>To use, run <strong>Terminal</strong>, then type <strong>myvpn</strong>. The VPN client will prompt you for your username and password. You&#8217;ll then have to hit CTRL+Z to suspend the VPN client so the script can run the DNS updates; this part uses <strong>sudo</strong> to run the command as root, so you will probably need to type your Mac password immediately after hitting CTRL+Z. If you didn&#8217;t want to bother with the command line VPN client, you could just use your GUI Cisco VPN client, then run <strong>myworkdns</strong> from Terminal, which will still probably prompt you for your Mac password.</p>
<p>Hope others find this useful. If I find a cleaner way, I&#8217;ll post that too.</p>
]]></content:encoded>
			<wfw:commentRss>http://holyarmy.org/2008/07/fight-back-when-vpn-clients-mis-behave/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
