<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Your Mac Guy (and more)</title>
	<atom:link href="http://yourmacguy.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://yourmacguy.wordpress.com</link>
	<description>mac and linux tips/tricks</description>
	<lastBuildDate>Thu, 12 Nov 2009 21:43:06 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='yourmacguy.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/14b0d1f0ddab8a83fe474007561342d8?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Your Mac Guy (and more)</title>
		<link>http://yourmacguy.wordpress.com</link>
	</image>
			<item>
		<title>Configure Software iSCSI Load-balance Multipathing to vSphere Datastores</title>
		<link>http://yourmacguy.wordpress.com/2009/11/09/vsphere-iscsi-multipathing/</link>
		<comments>http://yourmacguy.wordpress.com/2009/11/09/vsphere-iscsi-multipathing/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 16:50:40 +0000</pubDate>
		<dc:creator>pmbuko</dc:creator>
				<category><![CDATA[Storage]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[iscsi]]></category>
		<category><![CDATA[multi-pathing]]></category>
		<category><![CDATA[round robin]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://yourmacguy.wordpress.com/?p=477</guid>
		<description><![CDATA[VMware vSphere 4 gives us the ability to actively use multiple iSCSI paths to reach a single LUN. You will need to use vSphere Client, your iSCSI storage management tools, and an ESX command-line interface (such as ssh, RCLI or vSphere Management Assistant) to get it working. This procedure can be used to add up [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yourmacguy.wordpress.com&blog=4297208&post=477&subd=yourmacguy&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>VMware vSphere 4 gives us the ability to actively use multiple iSCSI paths to reach a single LUN. You will need to use vSphere Client, your iSCSI storage management tools, and an ESX command-line interface (such as ssh, RCLI or vSphere Management Assistant) to get it working. This procedure can be used to add up to eight iSCSI paths per datastore, provided each path uses a unique physical NIC and that each physical NIC has a corresponding NIC on the iSCSI SAN side. In other words, setting up more paths on the VMware side than your iSCSI SAN can actually accommodate would be pointless.</p>
<p>This tutorial assumes that you are familiar with vSphere Client and can find your way around. Read on beyond the break.</p>
<p><span id="more-477"></span></p>
<h1><span style="font-weight:normal;">The Procedure</span></h1>
<p>This entire procedure must be repeated <strong><em>for each ESX host</em></strong> you want to set up iSCSI multipathing on. If you have a clustered VMware environment, you should set up multipathing on each node in your cluster. Each VMkernel interface you create for the purposes of iSCSI multipathing will need an IP address, so it&#8217;s important to make sure you have enough available IP addresses in the appropriate subnet(s) before proceeding.</p>
<p>For convenience, here&#8217;s the procedure summary, with links to the tutorial sections.</p>
<ol type="I">
<li><a href="#one">Create the vmkernel interfaces</a></li>
<li><a href="#two">Use your iSCSI management tools to allow these new interfaces to connect</a></li>
<li><a href="#three">Configure the software iSCSI initiator to use the new vmkx iSCSI ports</a></li>
<li><a href="#four">Configure Round Robin path selection for all iSCSI datastores</a></li>
<li><a href="#five">Reboot the ESX host</a></li>
</ol>
<h2><a name="one"></a><span style="font-weight:normal;">I. Create the vmkernel interfaces</span></h2>
<p>The first step is to create at least two VMkernel ports, bound to unique physical NICs. This is done in the vSphere Client.</p>
<ol>
<li>Select the <strong><em>Networking</em></strong> view from the ESX host&#8217;s <strong><em>Configuration</em></strong> tab.</li>
<li>Find the vSwitch that is connected to the physical NICs you&#8217;d like to use for iSCSI multipathing and click the <strong><em>Properties</em></strong> link.</li>
<li>Click the <strong><em>Add</em></strong> button, select <strong><em>VMkernel</em></strong> and click Next.</li>
<li>Give a descriptive network label. I recommend &#8220;vmk<span style="color:#ff6600;"><em>x</em></span>-iSCSI&#8221;, where <span style="color:#ff6600;"><em>x</em></span> is the actual port number. I&#8217;ll be using this naming convention during this tutorial. (If you only have one existing VMkernel port, then it is vmk0. The next one you create will be vmk1. The one after that will be vmk2, etc.) Do not enable VMotion on this port. Click <strong><em>Next</em></strong>.</li>
<li>Enter the port&#8217;s IP address and subnet mask, then click <strong><em>Next</em></strong> and <strong><em>Finish</em></strong>.<br />
<img class="alignnone size-full wp-image-484" title="iscsi-1" src="http://yourmacguy.files.wordpress.com/2009/11/iscsi-1.png?w=754&#038;h=548" alt="iscsi-1" width="754" height="548" /></li>
<li>Select the new port from the list in the vSwitch Properties window, click the <strong><em>Edit</em></strong> button, and then select the <strong><em>NIC Teaming</em></strong> tab.</li>
<li>Enable <strong><em>Override vSwitch failover order</em></strong>, and then select one vmnic to be in the <strong><em>Active Adapters</em></strong> section and move the rest to the <strong><em>Unused Adapters</em></strong> section. (Make sure you choose a different vmnic for each vmk<span style="color:#ff6600;"><em>x</em></span>-iSCSI port!) Click <strong><em>OK</em></strong>.<br />
<img class="alignnone size-full wp-image-485" title="iscsi-2" src="http://yourmacguy.files.wordpress.com/2009/11/iscsi-2.png?w=526&#038;h=650" alt="iscsi-2" width="526" height="650" /></li>
<li>Repeat steps 3 &#8211; 7 for each additional you wish to create, then close the vSwitch Properties window.</li>
</ol>
<h2><a name="two"></a><span style="font-weight:normal;">II. Use your iSCSI management tools to allow these new interfaces to connect</span></h2>
<p>Since all environments are different, I can&#8217;t tell you how to do this step. Our iSCSI setup uses IP address access lists, so in this section, I would add the IP addresses of the VMkernel interfaces I added in the previous section to the access list.</p>
<h2><strong><a name="three"></a><span style="font-weight:normal;">III. Configure the software iSCSI initiator to use the new vmk</span><span style="color:#ff6600;"><em><span style="font-weight:normal;">x</span></em></span><span style="font-weight:normal;"> iSCSI ports</span></strong></h2>
<ol>
<li>In vSphere Client, select the <strong><em>Storage Adapters</em></strong> view from the ESX host&#8217;s <strong><em>Configuration</em></strong> tab and note the <strong><em>iSCSI Software Adapter</em></strong> device name. It&#8217;s <strong><em>vmhba33</em></strong> in our environment.</li>
<li>Using a command-line interface to the ESX host, add a vmk adapter to the software iSCSI initiator with this command:
<div>
<div>
<pre>esxcli swiscsi nic add -n vmk<span style="color:#ff6600;">x</span> -d vmhba33</pre>
</div>
</div>
</li>
<li>Repeat step 2 for each vmk<span style="color:#ff6600;"><em>x</em></span> interface you created in section I.</li>
<li>Back in vSphere Client, right-click on the <strong><em>iSCSI Software Adapter</em></strong> and choose <strong><em>Rescan</em></strong> to discover the additional paths to your storage. After a short wait, you should see in the Details section the available paths multiply by the number of VMkernel ports you added. E.g. If you are attached to 16 datastores and you added two iSCSI paths to them, your paths count should increase from 16 to 32.</li>
</ol>
<p>NOTE: It is common for the path number to be incorrect at this stage. In my case, it showed 48 paths &#8212; which is the original 16 plus the 32 new ones. Rebooting the ESX host will fix this, but you can save the reboot until the entire process is complete.</p>
<h2><a name="four"></a><span style="font-weight:normal;">IV. Configure Round Robin path selection for all iSCSI datastores</span></h2>
<p>To actually take advantage of these multiple iSCSI paths, you need to set your datastores to use the Round Robin path selection method so all paths can be active. The following procedure must be completed for <strong><em>each</em></strong> iSCSI datastore your ESX host accesses.</p>
<ol>
<li>In vSphere Client, select the <strong><em>Storage</em></strong> view from the ESX host&#8217;s <strong><em>Configuration</em></strong> tab.</li>
<li>Select one of your iSCSI datastores and click the <strong><em>Properties</em></strong> link.</li>
<li>Click the <strong><em>Managed Paths</em></strong> button.<br />
<img class="alignnone size-full wp-image-486" title="iscsi-3" src="http://yourmacguy.files.wordpress.com/2009/11/iscsi-3.png?w=708&#038;h=541" alt="iscsi-3" width="708" height="541" /></li>
<li>Select <strong><em>Round Robin (VMware)</em></strong> from the <strong><em>Path Selection</em></strong> menu and click <strong><em>Close</em></strong>.<br />
<img class="alignnone size-full wp-image-487" title="iscsi-4" src="http://yourmacguy.files.wordpress.com/2009/11/iscsi-4.png?w=727&#038;h=526" alt="iscsi-4" width="727" height="526" /></li>
<li>Click <strong><em>Close</em></strong>, and then wait for the task to finish.</li>
<li>Repeat steps 2 &#8211; 6 for each iSCSI datastore.</li>
</ol>
<h2><a name="five"></a><span style="font-weight:normal;">V. Reboot the ESX host</span></h2>
<p>If your environment is clustered, rebooting an individual host shouldn&#8217;t be too much trouble. After the reboot, the correct number of paths to your datastores should be reported.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yourmacguy.wordpress.com/477/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yourmacguy.wordpress.com/477/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yourmacguy.wordpress.com/477/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yourmacguy.wordpress.com/477/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yourmacguy.wordpress.com/477/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yourmacguy.wordpress.com/477/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yourmacguy.wordpress.com/477/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yourmacguy.wordpress.com/477/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yourmacguy.wordpress.com/477/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yourmacguy.wordpress.com/477/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yourmacguy.wordpress.com&blog=4297208&post=477&subd=yourmacguy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://yourmacguy.wordpress.com/2009/11/09/vsphere-iscsi-multipathing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61f2957855ade40d46a4549a3579bedf?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">pmbuko</media:title>
		</media:content>

		<media:content url="http://yourmacguy.files.wordpress.com/2009/11/iscsi-1.png" medium="image">
			<media:title type="html">iscsi-1</media:title>
		</media:content>

		<media:content url="http://yourmacguy.files.wordpress.com/2009/11/iscsi-2.png" medium="image">
			<media:title type="html">iscsi-2</media:title>
		</media:content>

		<media:content url="http://yourmacguy.files.wordpress.com/2009/11/iscsi-3.png" medium="image">
			<media:title type="html">iscsi-3</media:title>
		</media:content>

		<media:content url="http://yourmacguy.files.wordpress.com/2009/11/iscsi-4.png" medium="image">
			<media:title type="html">iscsi-4</media:title>
		</media:content>
	</item>
		<item>
		<title>Create a Leopard to Snow Leopard Upgrade NetInstall Image</title>
		<link>http://yourmacguy.wordpress.com/2009/10/13/leopard-to-snow-leopard-upgrade-netinstall/</link>
		<comments>http://yourmacguy.wordpress.com/2009/10/13/leopard-to-snow-leopard-upgrade-netinstall/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 18:30:54 +0000</pubDate>
		<dc:creator>pmbuko</dc:creator>
				<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Imaging]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[10.4]]></category>
		<category><![CDATA[10.5]]></category>
		<category><![CDATA[10.6]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[leopard]]></category>
		<category><![CDATA[netboot]]></category>
		<category><![CDATA[netinstall]]></category>
		<category><![CDATA[snow leopard]]></category>
		<category><![CDATA[tiger]]></category>
		<category><![CDATA[upgrade]]></category>
		<category><![CDATA[workaround]]></category>

		<guid isPermaLink="false">http://yourmacguy.wordpress.com/?p=377</guid>
		<description><![CDATA[UPDATE (10/15/09): I&#8217;ve gotten mixed results from some individuals who&#8217;ve tried the workaround with 10.6.1. I&#8217;m working on and testing an extended workaround that should fix the problem for everyone. Look for that info soon.
— — — —
UPDATE (10/13/09): I&#8217;ve updated the article (and posted it as new) with a workaround for the issue that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yourmacguy.wordpress.com&blog=4297208&post=377&subd=yourmacguy&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>UPDATE (10/15/09):</strong> I&#8217;ve gotten mixed results from some individuals who&#8217;ve tried the workaround with 10.6.1. I&#8217;m working on and testing an extended workaround that <em>should</em> fix the problem for everyone. Look for that info soon.</p>
<p>— — — —</p>
<p><strong>UPDATE (10/13/09)</strong>: I&#8217;ve updated the article (and posted it as new) with a workaround for the issue that prevented additional packages from being installed. I submitted the bug that this workaround avoids to Apple &#8212; id #7247968 &#8212; on September 23, 2009.</p>
<p>— — — —</p>
<p>This post is a Snow Leopard update to <a href="http://yourmacguy.wordpress.com/2008/07/25/tiger-to-leopard-upgrade-netinstall/">a process I wrote about when Leopard (10.5) came out</a>. This post will tell you how to create a NetInstall image that will upgrade a Mac running Leopard to the latest version of Snow Leopard in one step. It will also work to upgrade a Mac running Tiger to the latest version of Snow Leopard.</p>
<h3>What You&#8217;ll Need</h3>
<ol>
<li>A 10.6 software license, or individual retail copy of Leopard, for each computer you are upgrading from Leopard or Tiger to Snow Leopard — this is easily overlooked, so let’s keep things legal.</li>
<li>A read/write disk image (.dmg) of a <a title="dvd image" href="http://yourmacguy.files.wordpress.com/2009/09/snowleopard-dvd.jpg">Mac OS X v10.6 Snow Leopard Install DVD</a> (i.e. not shipped with a computer). You’ll convert this to read-only after making a small modification to one of the files.</li>
<li>One build computer running Snow Leopard with the latest version of Snow Leopard’s <a title="download" href="http://support.apple.com/kb/DL914">Server Admin Tools installed</a> (10.6.0 as of this writing).</li>
<li>A computer running OS X Server providing NetBoot services — Tiger, Leopard, and Snow Leopard Server will all work</li>
<li>A copy of the OSUpgrade.pkg found on the Install DVD at /Volumes/Mac OS X Install DVD/System/Installation/Packages. This is a hidden folder, so use Go to Folder from the Finder’s Go menu to reveal it.</li>
<li>Optional: the latest <a title="download" href="http://support.apple.com/kb/DL930">Combo Updater</a> — 10.6.1 as of this writing. (Yes, it’s not a Combo Update, but only because it’s a .1 updater.)</li>
</ol>
<h3>I. Make a Read-Write Installer Disk Image</h3>
<p>As of Mac OS 10.5.7, there has been a bug in in the OS installer that prevents you from successfully adding sizeable packages to your System Image Utility. Fortunately, there is a workaround. I’ll walk you through how to implement it here.</p>
<ol>
<li>Insert the OS Install DVD into your drive and then launch Disk Utility (found in /Applications/Utilities).</li>
<li>Select the Install DVD from the list on the left, then click the <strong><em>New Image</em></strong> icon in the toolbar.<img class="aligncenter wp-image-460" title="Disk Utility 1" src="http://yourmacguy.files.wordpress.com/2009/09/dmg1.png?w=500" alt="Disk Utility" /></li>
<li>Rename the image if you like, choose a location to save it, and change the Image Format option to <strong><em>read/write</em></strong>. Click <em><strong>Save</strong></em> to create the read/write disk image.<img class="aligncenter wp-image-461" title="Disk Utility 2" src="http://yourmacguy.files.wordpress.com/2009/09/dmg2.png?w=340" alt="Disk Utility Save" /></li>
<li>When the disk image is done, eject the DVD, select the disk image on the left side of the window, and click the <strong><em>Open</em></strong> icon in the toolbar to mount it.</li>
</ol>
<h3>II. Modify the Disk Image</h3>
<p>The reason we need to modify the disk image is because, since 10.5.7, the System Image Utility can’t properly handle additional packages that you add into your workflow. During startup &#8212; whether from DVD or via NetBoot &#8212; the installer creates a RAM disk to hold the contents of the /private/var directory. This is where additional packages get placed. The RAM disk size specified by Apple’s installer is too small to hold anything buy payloadless packages. The following instructions walk you through changing the size of this RAM disk to better accommodate additional packages.</p>
<ol>
<li>Open Terminal, navigate to the /etc/ directory <em>on the disk image</em> and open the <code>rc.cdrom</code> file in your favorite text editor. This file is marked as read-only, so I like to use vi as it allows you to easily write to read-only files. This command will open the file in vi:<br />
<code>vi /Volumes/Mac\ OS\ X\ Install\ DVD/etc/rc.cdrom</code></li>
<li>The line you’ll need to modify is ‘<code>RAMDisk /var/run 1024</code>’. Change <code>1024</code> to <code>1048576</code> and force vi to write the read-only file. 1048576 is equivalent to 512mb &#8212; we&#8217;re specifying sectors, which are 512 bytes each &#8212; which should be sufficient for any additional packages you want to include in your upgrade NetInstall image. If your vi skills are rusty or missing, follow these step to make this change.
<ol>
<li>Use the arrow keys to move the cursor down to the ‘<code>RAMDisk /var/run 1024</code>’ line and onto the <code>1</code> in <code>1024</code>.</li>
<li>Type <code>cw</code> &#8212; short for “change word”. The <code>1024</code> will disappear and vi will enter insert mode, which allows you to add characters to the file.</li>
<li>Type <code>1048576</code></li>
<li>Press the Esc key to exit insert mode.</li>
<li>Type <code>:x!</code> to force the read-only file to be saved and exit vi.</li>
</ol>
</li>
<li>Exit Terminal.</li>
</ol>
<h3>III. Convert the Disk Image to Read-only/Compressed</h3>
<ol>
<li>Go back to Disk Utility, select the mounted disk image on the left side of the window and click the <strong><em>Unmount</em></strong> icon in the toolbar.</li>
<li>Select the disk image and click the <strong><em>Convert</em></strong> icon in the toolbar.</li>
<li>Choose <strong><em>compressed</em></strong> from the Image Format menu. Rename the disk image so you know it’s the one you’ve modified, or save it in a different location from your read/write image. Click <strong><em>Save</em></strong> to begin the conversion.</li>
<li>Exit Disk Utility after the conversion is complete.</li>
</ol>
<p>Keep this disk image in a safe place as you&#8217;ll be able to re-use it when you want to create an updated NetInstall image &#8212; say when the 10.6.2 Combo Update is released.</p>
<h3>IV. Build your NetInstall Image</h3>
<p>If you haven&#8217;t yet made a DMG from the Mac OS X v10.6 Leopard Install DVD, do it now. (I use Disk Utility to create a default compressed image.) Mount the disk image and then launch the <strong>System Image Utility</strong> found in /Applications/Server. The program will auto-detect the mounted disk image as a source and select the NetInstall Image build option.</p>
<p><img class="aligncenter wp-image-378" title="LtoSL1" src="http://yourmacguy.files.wordpress.com/2009/09/ltosl1.png?w=500" alt="LtoSL1" /></p>
<p style="text-align:left;">Click <em><strong>Customize</strong></em> at the bottom of the window to bring up the workflow assembly interface.</p>
<p><img class="aligncenter wp-image-379" title="LtoSL2" src="http://yourmacguy.files.wordpress.com/2009/09/ltosl2.png?w=700" alt="LtoSL2" /></p>
<p style="text-align:left;">The idea here is to drag and drop the components you want from the Automator Library window to the workflow area. The <em><strong>Define Image Source</strong></em> item is added for you at the top, with the <strong><em>Create Image</em></strong> item below it. We&#8217;re going to build the simplest possible custom upgrade image, so we&#8217;ll add only one more item to our workflow.</p>
<p style="text-align:left;">First, select the <em><strong>Add Packages and Post-Install Scripts</strong></em> item and drag it over in between the two existing items. Now go to the Finder and locate the OSUpgrade package. and the latest Combo Updater for Snow Leopard. You&#8217;ll have to grab the package from the mounted update dmg. (10.6.1 isn&#8217;t a combo update since there are no previous updates, but it will work just fine.) Drag the package into the list area of the <em><strong>Add Packages and Post-Install Scripts</strong></em> item.</p>
<p><img class="aligncenter wp-image-403" title="LtoSL3.1" src="http://yourmacguy.files.wordpress.com/2009/09/ltosl3-1.png?w=500" alt="LtoSL3.1" /></p>
<p>Then, in the <em><strong>Create Image</strong></em> item at the bottom of your workflow, make sure the <strong><em>NetInstall</em></strong> option is selected in the <strong><em>Type</em></strong> section. Click the <em><strong>Save To</strong></em> drop down and select <em><strong>Other</strong></em>. Select your boot drive from the Devices list in the sidebar and click <em><strong>Open</strong></em>. (You can save directly to a network volume if you want to save yourself a step later, but I like to save mine locally so a network hiccup won&#8217;t interrupt the image build process.)</p>
<p><img class="aligncenter wp-image-381" title="LtoSL4" src="http://yourmacguy.files.wordpress.com/2009/09/ltosl4.png?w=500" alt="LtoSL4" /></p>
<p>You can probably ignore the <em><strong>Installed Volume</strong></em> field since we&#8217;re working on an upgrade, but you can supply the standard volume name of the Macs you manage here. In the <strong><em>Image Name</em></strong> field, enter a descriptive name. In the <em><strong>Network Disk</strong></em> field, enter a name that you&#8217;d like the NetInstall set to be advertised as on the network. (If your network is set up to advertise your NetBoot server across the network, your NetBoot/NetInstall volumes will appear in the Startup Disk preferences pane of all the Macs on your network.) Enter a <em><strong>Description</strong></em> if you wish, and then enter a unique <em><strong>Index</strong></em> number. Choose a number between 1-4095 if you have a single NetBoot server. Choose a number between 4096-65335 if you have more than one NetBoot server in a load-balanced configuration.</p>
<p>Now click <em><strong>Save</strong></em> to save the workflow. When a new Combo Updater comes out later, you&#8217;ll be able to use this workflow and just drag that package in &#8212; removing any older Combo Updaters, of course.</p>
<p>To build the image, click <em><strong>Run</strong></em>. In a few moments, you&#8217;ll be asked for your admin credentials, after which the build process will begin. If you want to track the progress, go to the <em><strong>View</strong></em> menu and select <em><strong>Show Log</strong></em>. This is a relatively quick build, so hang around unless you really need a coffee. It should take well under 30 minutes, and as little as 10 with recent hardware.</p>
<h3>It&#8217;s done! Now what?</h3>
<p>Ok, so your NetInstall image was created successfully. All that&#8217;s left to do now is to copy it to your server&#8217;s (or servers&#8217;) NetBootSP<em>x</em> share(s). (I have mine shared via AFP, but your environment may be different.) After you&#8217;ve transferred it, use Server Admin to enable the new NetBoot image. Assuming your network is set up in a NetBoot-friendly way, you should now be able to upgrade any Mac under your control from Leopard (or Tiger) to Snow Leopard by booting it with this NetInstall image.</p>
<p>Don&#8217;t forget to <strong>test</strong>, <strong>test</strong>, <strong>test</strong> before using this in production.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yourmacguy.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yourmacguy.wordpress.com/377/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yourmacguy.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yourmacguy.wordpress.com/377/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yourmacguy.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yourmacguy.wordpress.com/377/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yourmacguy.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yourmacguy.wordpress.com/377/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yourmacguy.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yourmacguy.wordpress.com/377/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yourmacguy.wordpress.com&blog=4297208&post=377&subd=yourmacguy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://yourmacguy.wordpress.com/2009/10/13/leopard-to-snow-leopard-upgrade-netinstall/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61f2957855ade40d46a4549a3579bedf?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">pmbuko</media:title>
		</media:content>

		<media:content url="http://yourmacguy.files.wordpress.com/2009/09/dmg1.png?w=500" medium="image">
			<media:title type="html">Disk Utility 1</media:title>
		</media:content>

		<media:content url="http://yourmacguy.files.wordpress.com/2009/09/dmg2.png?w=340" medium="image">
			<media:title type="html">Disk Utility 2</media:title>
		</media:content>

		<media:content url="http://yourmacguy.files.wordpress.com/2009/09/ltosl1.png?w=500" medium="image">
			<media:title type="html">LtoSL1</media:title>
		</media:content>

		<media:content url="http://yourmacguy.files.wordpress.com/2009/09/ltosl2.png?w=700" medium="image">
			<media:title type="html">LtoSL2</media:title>
		</media:content>

		<media:content url="http://yourmacguy.files.wordpress.com/2009/09/ltosl3-1.png?w=500" medium="image">
			<media:title type="html">LtoSL3.1</media:title>
		</media:content>

		<media:content url="http://yourmacguy.files.wordpress.com/2009/09/ltosl4.png?w=500" medium="image">
			<media:title type="html">LtoSL4</media:title>
		</media:content>
	</item>
		<item>
		<title>Open a Root Finder Window in Snow Leopard</title>
		<link>http://yourmacguy.wordpress.com/2009/09/28/snow-leopard-root-finder/</link>
		<comments>http://yourmacguy.wordpress.com/2009/09/28/snow-leopard-root-finder/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 17:30:16 +0000</pubDate>
		<dc:creator>pmbuko</dc:creator>
				<category><![CDATA[Terminal tricks]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://yourmacguy.wordpress.com/?p=450</guid>
		<description><![CDATA[This is a Snow Leopard update to an existing post about the same topic. Yes, you can still open a root Finder window in Snow Leopard, but there is an extra step required.
First, run the following command in Terminal and then enter your password:
sudo /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder
Next, click on an empty spot on your desktop &#8212; not [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yourmacguy.wordpress.com&blog=4297208&post=450&subd=yourmacguy&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This is a Snow Leopard update to an <a title="self-link" href="http://yourmacguy.wordpress.com/2009/07/31/finder-with-root-access/">existing post about the same topic</a>. Yes, you can still open a root Finder window in Snow Leopard, but there is an extra step required.</p>
<p>First, run the following command in Terminal and then enter your password:</p>
<pre style="padding-left:30px;">sudo /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder</pre>
<p>Next, click on an empty spot on your desktop &#8212; not in an existing Finder window. Now, type <strong><em>Command-N</em></strong> or select <strong><em>New Finder Window</em></strong> from the <strong><em>File</em></strong> menu. A new Finder window resembling the following should open:</p>
<p><img class="aligncenter size-full wp-image-312" title="root-window" src="http://yourmacguy.files.wordpress.com/2009/07/root-window.png?w=663&#038;h=417" alt="root-window" width="663" height="417" /></p>
<p>You can see that it opens up to the root user&#8217;s home. Use this window to navigate anywhere you like and make the changes you need. <em><strong>Keep in mind that you can do just as much damage with this as you can in the Terminal as root.</strong></em></p>
<p>To end your root Finder session, go back to the Terminal window and hit ^C.</p>
<h2>Quirks to be Mindful of</h2>
<ul>
<li>You won&#8217;t be able to interact with any files you might have on your desktop, as those belong to your logged-in user account and root&#8217;s desktop is currently (and transparently) sitting on top of it.</li>
<li>If you take any screenshots, they will be owned by the logged-in user and you&#8217;ll need to navigate to them via your root Finder window.</li>
<li>If you attempt to open/double-click a file which requires root access to read, the corresponding application will open as the logged-in user and the file will fail to open. To get around this, you can launch the app&#8217;s /Contents/MacOS executable as root and open the file from within the app.</li>
</ul>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yourmacguy.wordpress.com/450/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yourmacguy.wordpress.com/450/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yourmacguy.wordpress.com/450/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yourmacguy.wordpress.com/450/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yourmacguy.wordpress.com/450/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yourmacguy.wordpress.com/450/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yourmacguy.wordpress.com/450/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yourmacguy.wordpress.com/450/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yourmacguy.wordpress.com/450/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yourmacguy.wordpress.com/450/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yourmacguy.wordpress.com&blog=4297208&post=450&subd=yourmacguy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://yourmacguy.wordpress.com/2009/09/28/snow-leopard-root-finder/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61f2957855ade40d46a4549a3579bedf?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">pmbuko</media:title>
		</media:content>

		<media:content url="http://yourmacguy.files.wordpress.com/2009/07/root-window.png" medium="image">
			<media:title type="html">root-window</media:title>
		</media:content>
	</item>
		<item>
		<title>Get a Twitter Account&#8217;s Registration Date via Snow Leopard Service</title>
		<link>http://yourmacguy.wordpress.com/2009/09/12/twitter-reg-date-via-sl-services/</link>
		<comments>http://yourmacguy.wordpress.com/2009/09/12/twitter-reg-date-via-sl-services/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 05:43:07 +0000</pubDate>
		<dc:creator>pmbuko</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[automator]]></category>
		<category><![CDATA[services]]></category>
		<category><![CDATA[snow leopard]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://yourmacguy.wordpress.com/?p=406</guid>
		<description><![CDATA[Creating services in Snow Leopard is all the rage lately. So is Twitter. This tutorial brings both of them together and should serve as a fine example of just how slick and useful services in Snow Leopard can be.
Step 1: Write a script to grab a twitter account&#8217;s registration date
I recently became curious about how [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yourmacguy.wordpress.com&blog=4297208&post=406&subd=yourmacguy&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Creating <a title="link to Macworld article" href="http://www.macworld.com/article/142419/2009/08/snowleopardservices.html">services</a> in <a href="http://www.apple.com/macosx/">Snow Leopard</a> is all the rage lately. So is <a href="http://twitter.com/">Twitter</a>. This tutorial brings both of them together and should serve as a fine example of just how slick and useful services in Snow Leopard can be.<span id="more-406"></span></p>
<h2>Step 1: Write a script to grab a twitter account&#8217;s registration date</h2>
<p>I recently became curious about how long some of the people I follow have been on Twitter. Using <a title="Twitter API doc" href="http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-users%C2%A0show">this info from Twitter&#8217;s API documentation</a>, I made the following curl command to grab info on my own account:</p>
<pre>curl -s http://twitter.com/users/show.xml?screen_name=pmbuko</pre>
<p>This returns a bunch of info in XML format:</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;user&gt;
  &lt;id&gt;14845946&lt;/id&gt;
  &lt;name&gt;Peter Bukowinski&lt;/name&gt;
  &lt;screen_name&gt;pmbuko&lt;/screen_name&gt;
  &lt;location&gt;Virginia&lt;/location&gt;
  &lt;description&gt;IT geek, father of two, California ex-patriate, frequent flier&lt;/description&gt;
  &lt;profile_image_url&gt;http://a3.twimg.com/profile_images/368893865/wtfisthat_normal.jpg&lt;/profile_image_url&gt;
  &lt;url&gt;http://yourmacguy.wordpress.com&lt;/url&gt;
  &lt;protected&gt;false&lt;/protected&gt;
  &lt;followers_count&gt;80&lt;/followers_count&gt;
  &lt;profile_background_color&gt;E9DCBD&lt;/profile_background_color&gt;
  &lt;profile_text_color&gt;323232&lt;/profile_text_color&gt;
  &lt;profile_link_color&gt;FF5500&lt;/profile_link_color&gt;
  &lt;profile_sidebar_fill_color&gt;0055FF&lt;/profile_sidebar_fill_color&gt;
  &lt;profile_sidebar_border_color&gt;0000FF&lt;/profile_sidebar_border_color&gt;
  &lt;friends_count&gt;78&lt;/friends_count&gt;
  &lt;created_at&gt;Tue May 20 14:45:16 +0000 2008&lt;/created_at&gt;
  &lt;favourites_count&gt;11&lt;/favourites_count&gt;
  &lt;utc_offset&gt;-18000&lt;/utc_offset&gt;
  &lt;time_zone&gt;Eastern Time (US &amp;amp; Canada)&lt;/time_zone&gt;
  &lt;profile_background_image_url&gt;http://a3.twimg.com/profile_background_images/2548407/background3.jpg&lt;/profile_background_image_url&gt;
  &lt;profile_background_tile&gt;true&lt;/profile_background_tile&gt;
  &lt;statuses_count&gt;1361&lt;/statuses_count&gt;
  &lt;notifications&gt;false&lt;/notifications&gt;
  &lt;verified&gt;false&lt;/verified&gt;
  &lt;following&gt;false&lt;/following&gt;
  &lt;status&gt;
    &lt;created_at&gt;Sat Sep 12 01:38:58 +0000 2009&lt;/created_at&gt;
    &lt;id&gt;3924831726&lt;/id&gt;
    &lt;text&gt;@hotdogsladies That's the best description I've heard yet. You must be between Durant and Dwight.&lt;/text&gt;
    &lt;source&gt;&amp;lt;a href=&amp;quot;http://www.atebits.com/&amp;quot; rel=&amp;quot;nofollow&amp;quot;&amp;gt;Tweetie&amp;lt;/a&amp;gt;&lt;/source&gt;
    &lt;truncated&gt;false&lt;/truncated&gt;
    &lt;in_reply_to_status_id&gt;3924654818&lt;/in_reply_to_status_id&gt;
    &lt;in_reply_to_user_id&gt;749863&lt;/in_reply_to_user_id&gt;
    &lt;favorited&gt;false&lt;/favorited&gt;
    &lt;in_reply_to_screen_name&gt;hotdogsladies&lt;/in_reply_to_screen_name&gt;
  &lt;/status&gt;
&lt;/user&gt;</pre>
<p>The line that contains the info I want is the first &lt;created_at&gt; line, showing that I registered on May 20, 2008 &#8212; a relative late-comer, I know&#8230;. If you&#8217;ve visited this blog before, you&#8217;re likely aware of my love for awk. I&#8217;ll pipe curl&#8217;s output to awk to isolate the data I want:</p>
<pre>curl -s http://twitter.com/users/show.xml?screen_name=pmbuko | \
awk '/^  &lt;created_at&gt;/{sub("&lt;/created_at&gt;","");print $2" "$3", "$6}'</pre>
<p>This outputs &#8220;May 20, 2008&#8243; &#8212; great! Now let&#8217;s build a service with Automator that will allow us to right-click on any Twitter account name and have a dialog pop up with that account&#8217;s registration date.</p>
<h2>Step 2: Build a service with Automator</h2>
<p>Open up <strong><em>Automator.app</em><span style="font-weight:normal;">, found in your Applications folder</span></strong>. You&#8217;ll be presented with some workflow template choices. Double-click the <strong><em>Service</em></strong> item.</p>
<p><img class="aligncenter size-medium wp-image-410" title="SLS1" src="http://yourmacguy.files.wordpress.com/2009/09/sls1.png?w=600" alt="SLS1" /></p>
<p>Note that the Service template has an input section already at the top.</p>
<p><img class="aligncenter size-full wp-image-411" title="SLS2" src="http://yourmacguy.files.wordpress.com/2009/09/sls2.png" alt="SLS2" width="518" height="58" /></p>
<p>Leave the options set to defaults. Now type &#8220;<strong><em>shell&#8221;</em></strong> into the search box in the upper left area of the window and then drag the <strong><em>Run Shell Script</em></strong> action into the workflow area.</p>
<p><img class="aligncenter size-medium wp-image-412" title="SLS3" src="http://yourmacguy.files.wordpress.com/2009/09/sls3.png?w=600" alt="SLS3" /></p>
<p>Leave the <strong><em>Shell</em></strong> option set to <strong><em>/bin/bash</em></strong>, but change the <strong><em>Pass input</em></strong> option to <strong><em>as arguments</em></strong>. Replace the placeholder data in the script area with the following:</p>
<pre style="font:normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;">curl -s http://twitter.com/users/show.xml?screen_name=$1 | \
awk '/^  &lt;created_at&gt;/{sub("&lt;/created_at&gt;","");print $2" "$3", "$6}'</pre>
<p>Note that I used &#8220;<strong><em>$1</em></strong>&#8221; instead of an account name. In bash, the $1 variable in a script contains the first argument passed to the script. In this case, we&#8217;re passing whatever text we selected or right-clicked on to the script. Now we need a way to display the text on screen. AppleScript is perfect for this, so type &#8220;<strong><em>script</em></strong>&#8221; into the search box and then drag the <strong><em>Run AppleScript</em></strong> action to the bottom of the workflow area.</p>
<p><img class="aligncenter size-medium wp-image-442" title="SLS4.1" src="http://yourmacguy.files.wordpress.com/2009/09/sls4-1.png?w=600" alt="SLS4.1" /></p>
<p>Now, replace the contents of the script area with this:</p>
<pre>on run {regDate}
    tell application "Finder"
        activate
	display dialog "Twitter account registered on " &amp; regdate &amp; "." buttons{"OK"}
    end tell
end run</pre>
<p>The first line imports the info from the previous step to a variable named <strong><em>regDate</em></strong>. Then we&#8217;re telling the Finder to display a dialog with the text &#8220;Twitter account registered on [regDate].&#8221; Simple, right? Now click the hammer icon in the Applescript action to compile the script and check for errors. You&#8217;ll see the text change font and colors if all went well.</p>
<p><img class="aligncenter size-medium wp-image-416" title="SLS5.1" src="http://yourmacguy.files.wordpress.com/2009/09/sls5-1.png?w=600" alt="SLS5.1" /></p>
<h2>Step 3: Save and test the service</h2>
<p>You&#8217;re done building the service, so save it. I named mine <strong><em>Get Twit Age</em></strong>, but feel free to name yours however you want. Snow Leopard&#8217;s Automator will automatically save it in the correct location for use. In order to test this service, you need to be running a <a title="daringfireball" href="http://daringfireball.net/2009/09/itunes_and_cocoa">Cocoa application</a><sup><a title="daringfireball" href="http://daringfireball.net/2009/09/itunes_and_cocoa">1</a></sup> that has selectable text. Since we&#8217;re talking about Twitter, here, may I suggest Safari? Open the page of a Twitter user&#8217;s account (http://twitter.com/<em>username</em>) that you&#8217;d like to know the age of. Right-click on their account name and then select <strong><em>Get Twit Age</em></strong> (or whatever you called your service) near the bottom of the contextual menu. In a few moments, you should see a dialog box containing the account&#8217;s registration date.</p>
<p><img class="aligncenter size-full wp-image-423" title="SLS6.1" src="http://yourmacguy.files.wordpress.com/2009/09/sls6-1.png" alt="SLS6.1" width="436" height="228" /></p>
<p>And there you have it. If you happen to right-click on some text that doesn&#8217;t correspond to a twitter account, you won&#8217;t get an error but the dialog will simply display &#8220;Twitter account registered on .&#8221;</p>
<p>Hopefully, this tutorial gave you an idea of how easy it is to combine snippets of code to create a useful service. Now get out there and automate!</p>
<hr />1. John Gruber points out in his <a href="http://daringfireball.net/2009/09/itunes_and_cocoa">article about iTunes 9 and Cocoa</a> that while all apps can access system-wide services via the Services item in the Application menu, only Cocoa-based apps can access contextual services.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yourmacguy.wordpress.com/406/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yourmacguy.wordpress.com/406/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yourmacguy.wordpress.com/406/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yourmacguy.wordpress.com/406/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yourmacguy.wordpress.com/406/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yourmacguy.wordpress.com/406/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yourmacguy.wordpress.com/406/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yourmacguy.wordpress.com/406/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yourmacguy.wordpress.com/406/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yourmacguy.wordpress.com/406/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yourmacguy.wordpress.com&blog=4297208&post=406&subd=yourmacguy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://yourmacguy.wordpress.com/2009/09/12/twitter-reg-date-via-sl-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61f2957855ade40d46a4549a3579bedf?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">pmbuko</media:title>
		</media:content>

		<media:content url="http://yourmacguy.files.wordpress.com/2009/09/sls1.png?w=600" medium="image">
			<media:title type="html">SLS1</media:title>
		</media:content>

		<media:content url="http://yourmacguy.files.wordpress.com/2009/09/sls2.png" medium="image">
			<media:title type="html">SLS2</media:title>
		</media:content>

		<media:content url="http://yourmacguy.files.wordpress.com/2009/09/sls3.png?w=600" medium="image">
			<media:title type="html">SLS3</media:title>
		</media:content>

		<media:content url="http://yourmacguy.files.wordpress.com/2009/09/sls4-1.png?w=600" medium="image">
			<media:title type="html">SLS4.1</media:title>
		</media:content>

		<media:content url="http://yourmacguy.files.wordpress.com/2009/09/sls5-1.png?w=600" medium="image">
			<media:title type="html">SLS5.1</media:title>
		</media:content>

		<media:content url="http://yourmacguy.files.wordpress.com/2009/09/sls6-1.png" medium="image">
			<media:title type="html">SLS6.1</media:title>
		</media:content>
	</item>
		<item>
		<title>Recursively Find/Replace Inside Files Within a Directory</title>
		<link>http://yourmacguy.wordpress.com/2009/08/31/recursive-find-replace/</link>
		<comments>http://yourmacguy.wordpress.com/2009/08/31/recursive-find-replace/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 21:26:19 +0000</pubDate>
		<dc:creator>pmbuko</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[find/replace]]></category>
		<category><![CDATA[perl in place]]></category>
		<category><![CDATA[search/replace]]></category>
		<category><![CDATA[sed in place]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://yourmacguy.wordpress.com/?p=361</guid>
		<description><![CDATA[We recently had to change a handful of usernames in LDAP due to a merging of resources. This was a relatively painless process, but since some services use static authorization files to grant access, some manual post-processing was necessary. The script at the end of this post is something I came up with to deal [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yourmacguy.wordpress.com&blog=4297208&post=361&subd=yourmacguy&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>We recently had to change a handful of usernames in LDAP due to a merging of resources. This was a relatively painless process, but since some services use static authorization files to grant access, some manual post-processing was necessary. The script at the end of this post is something I came up with to deal with updating the subversion auth_files. It&#8217;s a bash script that uses a couple useful tricks:</p>
<pre><span style="color:#0000ff;">tree</span> -ifF --noreport /path/to/dir/ | <span style="color:#0000ff;">grep</span> -v '/$'</pre>
<ul>
<li>The tree command normally prints out an ascii-graphical representation of the file structure rooted in the given path, recursively. The &#8216;-i&#8217; option tells it not to display the graphics. The &#8216;-f&#8217; option prints out the full path to each item. The &#8216;-F&#8217; adds file-type indicators to the end of file names, which I&#8217;m using here so I can filter out directories from the list using an inverse grep.</li>
<li>The output of the tree command is piped to grep. The &#8216;-v&#8217; option activates inverse grep, and the &#8216;/$&#8217; regex will match trailing slashes. This grep will match all lines <em>not</em> ending in &#8216;/&#8217;.</li>
<li>The tree command is not standard on all flavors/versions of *nix. It&#8217;s missing on OS X, for example.</li>
</ul>
<pre><span style="color:#0000ff;">perl</span> -p -i -e 's|before|after|[ig]' file</pre>
<ul>
<li>This perl command will edit a file in-place, replacing occurrences of &#8220;before&#8221; with &#8220;after&#8221;.</li>
<li>Adding an <strong>i</strong> to the end of the substitution string makes it a case insensitive substitution.</li>
<li>Adding a <strong>g</strong> makes the command replace all instances, a.k.a. <em>global</em>, instead of just the first instance.</li>
</ul>
<h3>Why perl instead of sed for in-place edits?</h3>
<p><a href="http://en.wikipedia.org/wiki/Sed#History">Not all versions of sed</a> allow in-place edits, especially older ones, so perl is the more universal option. If you know your sed can do in-place edits (check the man page for the &#8216;-i&#8217; option), then you can replace the perl line in the script below with this:</p>
<pre>sed -i'' -e "s|$1|$2|g" $afile</pre>
<p>Whether you choose to use perl or sed, you must remember to double-quote the substitution string so bash expands the variables and hands the values off to sed/perl. Using single quotes here would result in sed/perl looking for a literal &#8216;$1&#8242; to replace with a literal &#8216;$2&#8242;.</p>
<h2>The Script</h2>
<p>This code can easily be repurposed for other tasks, but I present it here as I wrote it for the subversion auth_files purpose. (I named it &#8220;auth_find&#8221;.)</p>
<pre><span style="color:#888888;">#!/bin/bash</span>

workpath=/opt/auth_files/
outfile=/root/auth_find-$1

<span style="color:#888888;"># friendly usage funtion, called if no argument is supplied</span>
usage ()
{
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">""</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">"Usage: auth_find [username] [new-username]"</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">""</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">"This script recursively searches subversion's /opt/auth_files/ directory for"</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">"the supplied username and returns a list of files that contain it. If a second"</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">"username is supplied all instances of the first will be replaced with the second."</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">""</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">"Output is sent to both STDOUT and /root/auth_find-username."</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">""</span>
    <span style="color:#0000ff;">exit</span> 1
}

<span style="color:#0000ff;">if</span> [ $# == 1 ]; <span style="color:#0000ff;">then</span>    <span style="color:#888888;"># do this block if one argument is given</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">"Results:"</span>
    <span style="color:#0000ff;">for</span> afile <span style="color:#0000ff;">in</span> $(<span style="color:#0000ff;">tree</span> -ifF --noreport $workpath | <span style="color:#0000ff;">grep</span> -v '/$'); <span style="color:#0000ff;">do</span>
        <span style="color:#0000ff;">if</span> [ -n <span style="color:#ff00ff;">"$(</span><span style="color:#0000ff;">grep</span><span style="color:#ff00ff;"> "^$1 " $afile)"</span> ]; <span style="color:#0000ff;">then</span>
            <span style="color:#0000ff;">echo</span> "$afile" | <span style="color:#0000ff;">tee</span> -a $outfile
        <span style="color:#0000ff;">fi</span>
    <span style="color:#0000ff;">done</span>
<span style="color:#0000ff;">else</span>
    <span style="color:#0000ff;">if</span> [ $# == 2 ]; <span style="color:#0000ff;">then</span>    <span style="color:#888888;"># do this block if two arguments are given</span>
        <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">"Now replacing occurrences of '$1' with '$2' in the following files:"</span>
        <span style="color:#0000ff;">for</span> afile <span style="color:#0000ff;">in</span> $(<span style="color:#0000ff;">tree</span> -ifF --noreport $workpath | <span style="color:#0000ff;">grep</span> -v '/$'); <span style="color:#0000ff;">do</span>
            <span style="color:#0000ff;">if</span> [ -n <span style="color:#ff00ff;">"$(<span style="color:#0000ff;">grep</span> "^$1 " $afile)"</span> ]; <span style="color:#0000ff;">then</span>
                <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">"$afile"</span> | <span style="color:#0000ff;">tee</span> -a $outfile-CHANGED
                <span style="color:#0000ff;">perl</span> -p -i -e <span style="color:#ff00ff;">"s|$1|$2|g"</span> $afile
            <span style="color:#0000ff;">fi</span>
        <span style="color:#0000ff;">done</span>
    <span style="color:#0000ff;">else</span>    <span style="color:#888888;"># show usage if incorrect number of arguments given</span>
        usage
    <span style="color:#0000ff;">fi</span>
<span style="color:#0000ff;">fi</span>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">#!/bin/bash</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">outfile=/root/auth_find-$1</div>
</pre>
<p><strong>UPDATE (8/31/09):</strong> Added &#8220;why perl instead of sed&#8221; section in response to comment.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yourmacguy.wordpress.com/361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yourmacguy.wordpress.com/361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yourmacguy.wordpress.com/361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yourmacguy.wordpress.com/361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yourmacguy.wordpress.com/361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yourmacguy.wordpress.com/361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yourmacguy.wordpress.com/361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yourmacguy.wordpress.com/361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yourmacguy.wordpress.com/361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yourmacguy.wordpress.com/361/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yourmacguy.wordpress.com&blog=4297208&post=361&subd=yourmacguy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://yourmacguy.wordpress.com/2009/08/31/recursive-find-replace/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61f2957855ade40d46a4549a3579bedf?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">pmbuko</media:title>
		</media:content>
	</item>
		<item>
		<title>Can I boot Snow Leopard in 64-bit mode?</title>
		<link>http://yourmacguy.wordpress.com/2009/08/24/boot-snow-leopard-64-bit/</link>
		<comments>http://yourmacguy.wordpress.com/2009/08/24/boot-snow-leopard-64-bit/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 17:34:58 +0000</pubDate>
		<dc:creator>pmbuko</dc:creator>
				<category><![CDATA[Terminal tricks]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[10.6]]></category>
		<category><![CDATA[32-bit]]></category>
		<category><![CDATA[64]]></category>
		<category><![CDATA[64-bit]]></category>
		<category><![CDATA[snow leopard]]></category>

		<guid isPermaLink="false">http://yourmacguy.wordpress.com/?p=344</guid>
		<description><![CDATA[UPDATE: Please read Update 2 at the bottom of this post before using a 64-bit kernel as your default.
With Snow Leopard making its appearance this Friday, August 28, 2009, some people may be wondering whether they&#8217;ll be able to boot their Macs in 64-bit mode. Only Intel Xserves will boot this way by default. If [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yourmacguy.wordpress.com&blog=4297208&post=344&subd=yourmacguy&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>UPDATE: </strong>Please read Update 2 at the bottom of this post before using a 64-bit kernel as your default.</p>
<hr />With <a href="http://www.apple.com/pr/library/2009/08/24macosx.html">Snow Leopard making its appearance this Friday, August 28, 2009</a>, some people may be wondering whether they&#8217;ll be able to boot their Macs in 64-bit mode. <a href="http://arstechnica.com/apple/news/2009/08/latest-snow-leopard-build-limits-most-macs-to-32-bit-mode.ars">Only Intel Xserves will boot this way by default</a>. If you want to boot your desktop or mobile Mac in 64-bit mode, you&#8217;ll need to take some additional steps. The first is checking to see if your Mac has a 64-bit-capable EFI. If the output of the following command is <strong>EFI64</strong>, you&#8217;re good. If not, you&#8217;re out of luck.</p>
<pre>    ioreg -l -p IODeviceTree | awk -F'"' '/firmware-abi/{print $4}'</pre>
<p>Once you&#8217;ve verified it&#8217;s possible, you have a couple options for making your Mac boot into 64-bit mode. I&#8217;d try them in this order. First, to affect the current boot only, hold down the &#8216;6&#8242; and &#8216;4&#8242; keys during bootup. Once you&#8217;ve verified it works and are comfortable with it, you can make the change permanent by adding an &#8216;arch=x86_64&#8242; boot flag to your com.apple.Boot.plist, like so:</p>
<pre>    sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.Boot 'Kernel Flags' 'arch=x86_64'</pre>
<hr /><strong>UPDATE 1 (8/28/09)</strong>: Apple has a couple new (and one older) knowledge-base articles pertaining to this topic.</p>
<ol>
<li><a href="http://support.apple.com/kb/HT3770">Mac OS X Server v10.6: Macs that use the 64-bit kernel</a></li>
<li><a href="http://support.apple.com/kb/HT3773">Mac OS X Server v10.6: Starting up with the 32-bit or 64-bit kernel</a></li>
<li><a href="http://support.apple.com/kb/HT3696">How to tell if your Intel-based Mac has a 32-bit or 64-bit processor</a></li>
</ol>
<hr /><strong>UPDATE 2 (8/29/09):</strong> This post has received quite a few hits, so I now feel the need to include some educational material about why Apple chose to make Snow Leopard boot with a 32-bit kernel by default.</p>
<p>The primary reason is for compatibility with third-party software, particularly software that requires kernel extensions. Probably the most widely know examples of software that depends upon kernel extensions, or kexts, are VMware Fusion and Parallels. If you use these to run Windows or Linux on your Mac, you&#8217;ll want to keep using a 32-bit kernel. Virtualization software needs direct access to the hardware normally controlled by the kernel (CPU, RAM, Disk) in order to &#8220;fool&#8221; operating systems into thinking they&#8217;re installed on &#8220;real&#8221; computers. The kernel extensions allow them to do this.</p>
<p>Kexts must be written specifically for 32-bit <em>or</em> 64-bit kernels. They are not interchangeable. Applications, on the other hand, can run at 64-bit even if the kernel is 32-bit. As far as your 64-bit CPU is concerned, the kernel is just another application. It&#8217;s a very important application &#8212; in the sense that it is code that is executed on a processor &#8212; whose job it is to arbitrate demands on the system&#8217;s resources. Most applications don&#8217;t have direct access to the CPU, RAM, or other physical devices, but make requests of the kernel instead.</p>
<hr /><strong>UPDATE 3 (9/1/09):</strong> John Siracusa&#8217;s new article on Snow Leopard was posted today. Then entire thing is great reading, but <a href="http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/5">I&#8217;m linking to the section that addresses 64-bit vs 32-bit here</a>.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yourmacguy.wordpress.com/344/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yourmacguy.wordpress.com/344/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yourmacguy.wordpress.com/344/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yourmacguy.wordpress.com/344/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yourmacguy.wordpress.com/344/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yourmacguy.wordpress.com/344/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yourmacguy.wordpress.com/344/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yourmacguy.wordpress.com/344/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yourmacguy.wordpress.com/344/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yourmacguy.wordpress.com/344/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yourmacguy.wordpress.com&blog=4297208&post=344&subd=yourmacguy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://yourmacguy.wordpress.com/2009/08/24/boot-snow-leopard-64-bit/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61f2957855ade40d46a4549a3579bedf?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">pmbuko</media:title>
		</media:content>
	</item>
		<item>
		<title>Boost VirtualBox disk I/O for Windows VMs</title>
		<link>http://yourmacguy.wordpress.com/2009/08/21/boost-virtualbox-disk-io-for-windows-vms/</link>
		<comments>http://yourmacguy.wordpress.com/2009/08/21/boost-virtualbox-disk-io-for-windows-vms/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 18:38:48 +0000</pubDate>
		<dc:creator>pmbuko</dc:creator>
				<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[sun]]></category>
		<category><![CDATA[virtualbox]]></category>

		<guid isPermaLink="false">http://yourmacguy.wordpress.com/?p=336</guid>
		<description><![CDATA[I picked up a VirtualBox Windows VM optimization tip from the MacEnterprise mailing list this morning, supplied by Yadin Flammer. Yadin mentioned that switching your Windows VM&#8217;s disk type from the default IDE to SATA and using the Intel Matrix Storage drivers results in faster hardware emulation. I decided to verify this claim by collecting [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yourmacguy.wordpress.com&blog=4297208&post=336&subd=yourmacguy&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I picked up a <a href="http://www.virtualbox.org/">VirtualBox</a> Windows VM optimization tip from the <a href="http://www.macenterprise.org/mailing-list">MacEnterprise mailing list</a> this morning, supplied by <a href="http://lists.psu.edu/cgi-bin/wa?A2=ind0908&amp;L=macenterprise&amp;D=1&amp;T=0&amp;O=D&amp;P=270379">Yadin Flammer</a>. Yadin mentioned that switching your Windows VM&#8217;s disk type from the default IDE to SATA and using the Intel Matrix Storage drivers results in faster hardware emulation. I decided to verify this claim by collecting some before and after I/O data. I have a Windows XP VM, but this should apply to all versions of Windows from 2000 onward, both server and client.</p>
<p>I used the freely-available <a href="http://www.iometer.org">Iometer</a> to gather my disk I/O data. Both the before and after tests were run for 5 minutes on an ~ 3GB test file using the All-In-One test suite. Here are the results.</p>
<p><img class="aligncenter size-full wp-image-338" title="iops-chart" src="http://yourmacguy.files.wordpress.com/2009/08/iops-chart.png?w=384&#038;h=328" alt="iops-chart" width="384" height="328" />As you can see, the data clearly shows a slight increase in performance. Using SATA is actually recommended by Sun, as well. On <a href="http://www.virtualbox.org/wiki/Editions">this page</a>, they say,</p>
<blockquote><p>Like a real SATA controller, VirtualBox’s virtual SATA controller operates faster and also consumes less CPU resources than the virtual IDE controller. Also, this allows you to connect more than three virtual hard disks to the machine.</p></blockquote>
<p>Makes sense, no? In terms of MBps, my IDE test averaged 17.925 while my SATA test averaged 18.828. Now that we know it&#8217;s better, we&#8217;ll move on to the installation and configuration procedure.</p>
<h3>Installation and Configuration</h3>
<p><img class="aligncenter size-medium wp-image-339" title="vm-settings" src="http://yourmacguy.files.wordpress.com/2009/08/vm-settings.png?w=300&#038;h=232" alt="vm-settings" width="300" height="232" /></p>
<ol>
<li>Shut down your Windows VM and open its settings window (shown above).</li>
<li>Select the <strong>Hard Disks</strong> item, check <strong>Enable Additional Controller</strong> and choose <strong>SATA (AHCI) </strong>from the list.</li>
<li>Leave the Hard disk attached to the IDE Controller in the Attachments section for now, since we&#8217;ll first have to install the SATA drivers, and click OK.</li>
<li>Start up your VM again and download the <a href="http://downloadcenter.intel.com/Product_Filter.aspx?ProductID=2101">Intel Matrix Storage Manager drivers</a>. Click the link, select your Windows OS version, click Go, and then click the first download link in the Drivers section. Mine showed up as link #1. Save it to your desktop, and then install it. <strong><em>NOTE:</em></strong> If you are given a warning about not meeting the minimum installation requirements, you may need to download and install the <a href="http://downloadcenter.intel.com/Product_Filter.aspx?ProductID=816">Intel Chipset Software Installation Utility</a> first. Follow the same download and install procedure as for the storage drivers.</li>
<li>Once the drivers are installed, shut down your Windows VM and open its settings window.</li>
<li>Select the <strong>Hard Disks</strong> item as before, but now select <strong>SATA Port 0</strong> next to your VM&#8217;s .vdi file in the Attachments section.</li>
<li>Click OK and then start up your VM.</li>
</ol>
<p>&#8230; And boom goes the dynamite.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yourmacguy.wordpress.com/336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yourmacguy.wordpress.com/336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yourmacguy.wordpress.com/336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yourmacguy.wordpress.com/336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yourmacguy.wordpress.com/336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yourmacguy.wordpress.com/336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yourmacguy.wordpress.com/336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yourmacguy.wordpress.com/336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yourmacguy.wordpress.com/336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yourmacguy.wordpress.com/336/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yourmacguy.wordpress.com&blog=4297208&post=336&subd=yourmacguy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://yourmacguy.wordpress.com/2009/08/21/boost-virtualbox-disk-io-for-windows-vms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61f2957855ade40d46a4549a3579bedf?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">pmbuko</media:title>
		</media:content>

		<media:content url="http://yourmacguy.files.wordpress.com/2009/08/iops-chart.png" medium="image">
			<media:title type="html">iops-chart</media:title>
		</media:content>

		<media:content url="http://yourmacguy.files.wordpress.com/2009/08/vm-settings.png?w=300" medium="image">
			<media:title type="html">vm-settings</media:title>
		</media:content>
	</item>
		<item>
		<title>Print PDFs as Postscript to an lpr Queue</title>
		<link>http://yourmacguy.wordpress.com/2009/08/18/print-pdfs-as-postscript-to-an-lpr-queue/</link>
		<comments>http://yourmacguy.wordpress.com/2009/08/18/print-pdfs-as-postscript-to-an-lpr-queue/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 15:28:31 +0000</pubDate>
		<dc:creator>pmbuko</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[lpr]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[pdf2ps]]></category>
		<category><![CDATA[postscript]]></category>
		<category><![CDATA[ps]]></category>

		<guid isPermaLink="false">http://yourmacguy.wordpress.com/?p=321</guid>
		<description><![CDATA[I wrote a simple script recently for a user who was having trouble getting certain PDFs to print properly from his linux box (Fedora 10). I first suggested that he try converting the pdfs to ps and printing the resulting file. That worked but he found the process a bit tedious. Here&#8217;s the script I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yourmacguy.wordpress.com&blog=4297208&post=321&subd=yourmacguy&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I wrote a simple script recently for a user who was having trouble getting certain PDFs to print properly from his linux box (Fedora 10). I first suggested that he try converting the pdfs to ps and printing the resulting file. That worked but he found the process a bit tedious. Here&#8217;s the script I wrote to take care of the tediousness. It relies on the standard (in Fedora, at least) <strong>pdf2ps</strong> package. It should be pretty self-explanatory.</p>
<pre>
<span style="color:#808080;">#!/bin/bash

# grab first argument as pdf filename and generate ps filename</span>
thePDF=$1
thePS=$(<span style="color:#0000ff;">echo</span> $thePDF.ps)
queueName=$2

usage()
{
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">""</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">"Usage: psprint [your pdf] [lpr queue]*"</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">""</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">"This command does three things:"</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">"  1. Converts the specified pdf file to ps"</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">"  2. Prints the ps file to your default lpr queue *(unless you specify another queue)"</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">"  3. Deletes the ps file"</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">""</span>
    <span style="color:#0000ff;">exit</span> 1
}

<span style="color:#0000ff;">if</span> [ $# == 0 ]; <span style="color:#0000ff;">then</span> usage; <span style="color:#0000ff;">fi</span>
<span style="color:#0000ff;">if</span> [ $# == 1 ]; <span style="color:#0000ff;">then</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">"Converting $thePDF ..."</span>
    <span style="color:#0000ff;">pdf2ps</span> <span style="color:#ff00ff;">"$thePDF" "$thePS"</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">"Sending to default printer ..."</span>
    <span style="color:#0000ff;">lpr</span> <span style="color:#ff00ff;">"$thePS"</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">"Cleaning up ..."</span>
    <span style="color:#0000ff;">rm</span> <span style="color:#ff00ff;">"$thePS"</span>
    <span style="color:#0000ff;">exit</span> 1
<span style="color:#0000ff;">fi</span>
<span style="color:#0000ff;">if</span> [ $# == 2 ]; <span style="color:#0000ff;">then</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">"Converting $thePDF ..."</span>
    <span style="color:#0000ff;">pdf2ps</span> <span style="color:#ff00ff;">"$thePDF" "$thePS"</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">"Sending to $2 ..."</span>
    <span style="color:#0000ff;">lpr</span> -P <span style="color:#ff00ff;">"$queueName" "$thePS"</span>
    <span style="color:#0000ff;">echo</span> <span style="color:#ff00ff;">"Cleaning up ..."</span>
    <span style="color:#0000ff;">rm</span> <span style="color:#ff00ff;">"$thePS"</span>
    <span style="color:#0000ff;">exit</span> 1
<span style="color:#0000ff;">fi</span>
<span style="color:#0000ff;">if</span> [ $# &gt; 2 ]; <span style="color:#0000ff;">then</span> usage; <span style="color:#0000ff;">fi</span>
</pre>
<p>Save the script to a location in your path (/usr/local/bin works) and you&#8217;re off.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yourmacguy.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yourmacguy.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yourmacguy.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yourmacguy.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yourmacguy.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yourmacguy.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yourmacguy.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yourmacguy.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yourmacguy.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yourmacguy.wordpress.com/321/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yourmacguy.wordpress.com&blog=4297208&post=321&subd=yourmacguy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://yourmacguy.wordpress.com/2009/08/18/print-pdfs-as-postscript-to-an-lpr-queue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61f2957855ade40d46a4549a3579bedf?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">pmbuko</media:title>
		</media:content>
	</item>
		<item>
		<title>Open a Finder Window with Root Access</title>
		<link>http://yourmacguy.wordpress.com/2009/07/31/finder-with-root-access/</link>
		<comments>http://yourmacguy.wordpress.com/2009/07/31/finder-with-root-access/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 18:50:18 +0000</pubDate>
		<dc:creator>pmbuko</dc:creator>
				<category><![CDATA[Terminal tricks]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://yourmacguy.wordpress.com/?p=311</guid>
		<description><![CDATA[UPDATE (9/28/09): Got Snow Leopard? Please see this post for updated instructions.
— — — —
It&#8217;s occasionally handy when troubleshooting a problem in OS X to have root access in the Finder without having to log out of your current session. Sure, you can do most things in the Terminal, but the GUI can be much [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yourmacguy.wordpress.com&blog=4297208&post=311&subd=yourmacguy&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>UPDATE (9/28/09):</strong> Got Snow Leopard? Please see <a title="self-link" href="http://yourmacguy.wordpress.com/2009/09/28/snow-leopard-root-finder/">this post</a> for updated instructions.</p>
<p>— — — —</p>
<p>It&#8217;s occasionally handy when troubleshooting a problem in OS X to have root access in the Finder without having to log out of your current session. Sure, you can do most things in the Terminal, but the GUI can be much handier for certain tasks. This is a quick-and-dirty Terminal trick to open a Finder window with root access.</p>
<p>Run the following command and then enter your password:</p>
<pre style="padding-left:30px;">sudo /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder</pre>
<p>A new Finder window resembling the following should open:</p>
<p><img class="aligncenter size-full wp-image-312" title="root-window" src="http://yourmacguy.files.wordpress.com/2009/07/root-window.png?w=663&#038;h=417" alt="root-window" width="663" height="417" /></p>
<p>You can see that it opens up to the root user&#8217;s home. Use this window to navigate anywhere you like and make the changes you need. <em><strong>Keep in mind that you can do just as much damage with this as you can in the Terminal as root.</strong></em></p>
<p>To end your root Finder session, go back to the Terminal window and hit ^C.</p>
<h2>Quirks to be Mindful Of</h2>
<ul>
<li>You won&#8217;t be able to interact with any files you might have on your desktop, as those belong to your logged-in user account and root&#8217;s desktop is currently (and transparently) sitting on top of it.</li>
<li>If you take any screenshots, they will be owned by the logged-in user and you&#8217;ll need to navigate to them via your root Finder window.</li>
<li>If you attempt to open/double-click a file which requires root access to read, the corresponding application will open as the logged-in user and the file will fail to open. To get around this, you can launch the app&#8217;s /Contents/MacOS executable as root and open the file from within the app.</li>
</ul>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yourmacguy.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yourmacguy.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yourmacguy.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yourmacguy.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yourmacguy.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yourmacguy.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yourmacguy.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yourmacguy.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yourmacguy.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yourmacguy.wordpress.com/311/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yourmacguy.wordpress.com&blog=4297208&post=311&subd=yourmacguy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://yourmacguy.wordpress.com/2009/07/31/finder-with-root-access/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61f2957855ade40d46a4549a3579bedf?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">pmbuko</media:title>
		</media:content>

		<media:content url="http://yourmacguy.files.wordpress.com/2009/07/root-window.png" medium="image">
			<media:title type="html">root-window</media:title>
		</media:content>
	</item>
		<item>
		<title>Quickly Add a Userset to Many Sun Grid Engine Queues</title>
		<link>http://yourmacguy.wordpress.com/2009/06/01/quickly-add-a-userset-to-many-sun-grid-engine-queues/</link>
		<comments>http://yourmacguy.wordpress.com/2009/06/01/quickly-add-a-userset-to-many-sun-grid-engine-queues/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 20:48:51 +0000</pubDate>
		<dc:creator>pmbuko</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[cluster]]></category>
		<category><![CDATA[sge]]></category>
		<category><![CDATA[sun grid engine]]></category>

		<guid isPermaLink="false">http://yourmacguy.wordpress.com/?p=290</guid>
		<description><![CDATA[This will be the first (of many??) posts to spill outside the topics one would think you&#8217;d find on a site with the name &#8220;Your Mac Guy&#8221;. You&#8217;ve been warned.
Back in January my primary work responsibilities shifted from Mac servers and desktops (and all that entailed) to Linux servers and desktops and the multitude of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yourmacguy.wordpress.com&blog=4297208&post=290&subd=yourmacguy&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><em>This will be the first (of many??) posts to spill outside the topics one would think you&#8217;d find on a site with the name &#8220;Your Mac Guy&#8221;. You&#8217;ve been warned.</em></p>
<p><em><span style="font-style:normal;">Back in January my primary work responsibilities shifted from Mac servers and desktops (and all that entailed) to Linux servers and desktops and the multitude of new things that entails (at least <a title="HHMI Janelia Farm Research Campus" href="http://www.hhmi.org/janelia" target="_self">here where I work</a>). One of the new tasks I&#8217;ve picked up is user administration of our <a href="http://gridengine.sunsource.net/" target="_self">Sun Grid Engine </a>(SGE) 500-node cluster. New or existing users who want to submit jobs to the cluster need to be added to custom groups or, in SGE-speak, usersets. We create usersets for each lab, so if the user is part of a lab that doesn&#8217;t currently have access to submit jobs, I need to create a new userset and add that userset to each of 16 separate queues.</span></em></p>
<p><em><span style="font-style:normal;">That last part, adding usersets to queues, is the most tedious part. So tedious, in fact, that it forced my hand into developing a scripted solution. I likely could have found an existing script to accomplish the task for me, but then I wouldn&#8217;t have had an excuse to brush up on my 3-years dormant perl skills.</span></em></p>
<p><em><span style="font-style:normal;"><span id="more-290"></span></span></em></p>
<p><em><span style="font-style:normal;">With the help of a couple perl books, a dash of google, a short debugging session, and the successful execution of the product on our production cluster, I bring you the following code. I welcome any and all suggestions for improvement and general verbal lashings for poor form. Please note, if you intend to try it, just modify the <strong>$configpath </strong>variable and the <strong>@configs</strong> array to suit.</span></em></p>
<pre><span style="color:#808080;">#!/usr/bin/perl -w</span>
<span style="color:#0000ff;">use</span> strict;

<span style="color:#888888;"># This script automates the process of adding usersets to the user_lists section
# of the SGE cluster queue conf files. It takes the userset name as a command
# line argument or it prompts for the userset name if no argument is given.  It
# currently supports adding one userset at a time.</span>

<span style="color:#888888;"># Path to config files to be modified</span>
<span style="color:#0000ff;">my</span> $configpath=<span style="color:#ff00ff;">"/sge/current/default/spool/qmaster/cqueues/"</span>;

<span style="color:#888888;"># Filenames of queues to be modified</span>
<span style="color:#0000ff;">my</span> @configs = <span style="color:#0000ff;">qw</span><span style="color:#ff00ff;">(
	list.q
        your.q
        queue.q
        names.q
        here.q
	)</span>;

<span style="color:#0000ff;">my</span> $input=$ARGV[0];

<span style="color:#888888;"># If no arguments passed, print helpful info and prompt for userset name</span>
<span style="color:#0000ff;">if</span> (! <span style="color:#0000ff;">defined</span>($input)) {
	<span style="color:#0000ff;">print</span> <span style="color:#ff00ff;">"This command will add a new group to the user_lists line of the following\n"</span>;
	<span style="color:#0000ff;">print</span> <span style="color:#ff00ff;">"cluster queues:\n"</span>;
	<span style="color:#0000ff;">print</span> <span style="color:#ff00ff;">"@configs\n\n"</span>;

	<span style="color:#888888;"># Get input from STDIN.</span>
	<span style="color:#0000ff;">print</span> <span style="color:#ff00ff;">"Enter the name of the new userset (or ^c to exit): "</span>;
	<span style="color:#0000ff;">chomp</span>($input=&lt;STDIN&gt;);
}

<span style="color:#0000ff;">foreach my</span> $file (@configs) {

	<span style="color:#888888;"># open the file and dump all lines into an @LINES array.</span>
	<span style="color:#0000ff;">chdir</span>($configpath);
	<span style="color:#0000ff;">open</span>(CONF,$file) || <span style="color:#0000ff;">die</span> <span style="color:#ff00ff;">"Cannot open $file"</span>;
	<span style="color:#0000ff;">chomp</span>(<span style="color:#0000ff;">my</span>(@LINES)=&lt;CONF&gt;);
	<span style="color:#0000ff;">close</span>(CONF);

	<span style="color:#888888;"># create a new config file in /tmp</span>
	<span style="color:#0000ff;">open</span>(NEWCONF,<span style="color:#ff00ff;">"&gt;/tmp/$file"</span>) || <span style="color:#0000ff;">die</span> <span style="color:#ff00ff;">"Cannot create $file"</span>;
	<span style="color:#0000ff;">foreach my</span> $line (@LINES) {
		<span style="color:#888888;"># if the current line is the user_lists line</span>
		<span style="color:#0000ff;">if</span> ( $line =~ <span style="color:#0000ff;">m</span><span style="color:#ff00ff;">/^user_lists/</span> ) {
			<span style="color:#888888;"># add the new userset to the end of the user_lists line</span>
			<span style="color:#0000ff;">print</span> NEWCONF <span style="color:#ff00ff;">"$line $input\n"</span>;
		} <span style="color:#0000ff;">else</span> {  <span style="color:#888888;"># print the line unmodified</span>
			<span style="color:#0000ff;">print</span> NEWCONF <span style="color:#ff00ff;">"$line\n"</span>;
		}
	}
	<span style="color:#0000ff;">close</span>(NEWCONF);

	<span style="color:#888888;"># read in new config in place of old one</span>
	<span style="color:#0000ff;">system</span>(<span style="color:#ff00ff;">"qconf -Mq /tmp/$file"</span>);

	<span style="color:#888888;"># delete the temp config file</span>
	<span style="color:#0000ff;">unlink</span>(<span style="color:#ff00ff;">"/tmp/$file"</span>);
}</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yourmacguy.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yourmacguy.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yourmacguy.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yourmacguy.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yourmacguy.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yourmacguy.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yourmacguy.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yourmacguy.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yourmacguy.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yourmacguy.wordpress.com/290/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yourmacguy.wordpress.com&blog=4297208&post=290&subd=yourmacguy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://yourmacguy.wordpress.com/2009/06/01/quickly-add-a-userset-to-many-sun-grid-engine-queues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61f2957855ade40d46a4549a3579bedf?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">pmbuko</media:title>
		</media:content>
	</item>
	</channel>
</rss>