<?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>The Promised Lan &#187; for loop</title>
	<atom:link href="http://www.thepromisedlan.org/archives/tag/for-loop/feed" rel="self" type="application/rss+xml" />
	<link>http://www.thepromisedlan.org</link>
	<description>Metering Out Justice One Packet at a Time</description>
	<lastBuildDate>Mon, 11 Apr 2011 16:43:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>There must be a better way!</title>
		<link>http://www.thepromisedlan.org/archives/there-must-be-a-better-way</link>
		<comments>http://www.thepromisedlan.org/archives/there-must-be-a-better-way#comments</comments>
		<pubDate>Fri, 02 Oct 2009 20:10:52 +0000</pubDate>
		<dc:creator>sam</dc:creator>
				<category><![CDATA[Software Freedom]]></category>
		<category><![CDATA[for loop]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[sed]]></category>

		<guid isPermaLink="false">http://www.thepromisedlan.org/?p=74</guid>
		<description><![CDATA[<code>grep username modemconfigfile &#124;cut -d " " -f 2 &#124; for USER in `cat`; do grep $USER passwd > /dev/null; echo $USER $?; done &#124;grep 0 &#124;cut -d " " -f 1 &#124; sed s/$/@ourdomain.com/g &#124; tr '\n' ','</code>]]></description>
			<content:encoded><![CDATA[<p>So at work we have some rarely used dial-in modems. The users are all configured locally on the router with the modem bank, so modemconfigfile contains strings like this:<br />
<code>!username sam password &lt;removed&gt;</code></p>
<p>Well, I needed to send a brief message to all of the modem users, so I needed a way to translate a few dozen of the lines above into something I could paste into the bcc: bar of my mua. Also a few of them were not using their real email usernames for the modem.<br />
So given a handy local copy of the mail servers passwd file, here&#8217;s what I came up with:<br />
<code>grep username modemconfigfile |cut -d " " -f 2 | for USER in `cat`; do grep $USER passwd &gt; /dev/null; echo $USER $?; done |grep 0 |cut -d " " -f 1 | sed s/$/@ourdomain.com/g | tr '\n' ','</code></p>
<p>Which does indeed spit out a list of verified email addresses comma seperated, and ready to be pasted. It is still missing the real addresses of those users with different usernames, but there were only a few so I looked them up manually with the output of<br />
<code>grep username modemconfigfile |cut -d " " -f 2 | for USER in `cat`; do grep $USER passwd &gt; /dev/null; echo $USER $?; done |grep -v 0</code><br />
as a starting point.</p>
<p>Man I really need to learn perl or something. I couldn&#8217;t even fit that in an Identi.ca posting.</p>
<p>Update: DOH!, keen observers will have noticed that until this update, the above created output like user1.ourdomain.com, user2.ourdomain.com<br />
Which of course are not email addresses. So s/./@/ and we&#8217;re back on track.<br />
I guess that&#8217;s what I get for hours of DNS updating just previous. <img src='http://www.thepromisedlan.org/wordpress/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.thepromisedlan.org/archives/there-must-be-a-better-way/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

