<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Squawk (simple queues using awk)</title>
	<atom:link href="http://www.nobugs.org/blog/archives/2008/05/11/squawk-simple-queues-using-awk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nobugs.org/blog/archives/2008/05/11/squawk-simple-queues-using-awk/</link>
	<description>Thoughts of a software engineer</description>
	<lastBuildDate>Thu, 11 Mar 2010 02:14:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Andrew</title>
		<link>http://www.nobugs.org/blog/archives/2008/05/11/squawk-simple-queues-using-awk/comment-page-1/#comment-33393</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Wed, 14 May 2008 11:37:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.nobugs.org/blog/archives/2008/05/11/squawk-simple-queues-using-awk/#comment-33393</guid>
		<description>Ken:  Yep, that works fine if you are using netcat as a data source and filtering its output with awk.  But for squawk I also need the output from awk to be fed back into netcat&#039;s stdin - its a two way conversation.  I use netcat -c &quot;my_awk_command&quot; for this.  But that means my awk command invocation would need to be escaped otherwise bash will expand things like &#039;$0&#039; which I intend for awk.

Hmm, actually, I think in this case I can surround the awk invocation with single quotes and then consistently use double quotes within the awk script.  In an earlier version I was relying on the awk script being bash-expanded to do variable substitution for the queue name.  But now I explicitly pass the arguments in with --assign.

Ah, no .. I still need to shell-expand the --assign part of the awk invocation, so it can&#039;t be in single quotes.

This page has some suggestions; I&#039;ll see if I can get it to work: http://www.gnu.org/manual/gawk/html_node/Quoting.html.  I didn&#039;t know that if you run something like this:

ls &#039;foo&#039;&quot;bar&quot;  (no space between the quotes)

.. then ls receives a single argument - I&#039;d always assumed it&#039;d get two arguments.</description>
		<content:encoded><![CDATA[<p>Ken:  Yep, that works fine if you are using netcat as a data source and filtering its output with awk.  But for squawk I also need the output from awk to be fed back into netcat&#8217;s stdin &#8211; its a two way conversation.  I use netcat -c &#8220;my_awk_command&#8221; for this.  But that means my awk command invocation would need to be escaped otherwise bash will expand things like &#8216;$0&#8242; which I intend for awk.</p>
<p>Hmm, actually, I think in this case I can surround the awk invocation with single quotes and then consistently use double quotes within the awk script.  In an earlier version I was relying on the awk script being bash-expanded to do variable substitution for the queue name.  But now I explicitly pass the arguments in with &#8211;assign.</p>
<p>Ah, no .. I still need to shell-expand the &#8211;assign part of the awk invocation, so it can&#8217;t be in single quotes.</p>
<p>This page has some suggestions; I&#8217;ll see if I can get it to work: <a href="http://www.gnu.org/manual/gawk/html_node/Quoting.html" rel="nofollow">http://www.gnu.org/manual/gawk/html_node/Quoting.html</a>.  I didn&#8217;t know that if you run something like this:</p>
<p>ls &#8216;foo&#8217;&#8221;bar&#8221;  (no space between the quotes)</p>
<p>.. then ls receives a single argument &#8211; I&#8217;d always assumed it&#8217;d get two arguments.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ken horn</title>
		<link>http://www.nobugs.org/blog/archives/2008/05/11/squawk-simple-queues-using-awk/comment-page-1/#comment-33390</link>
		<dc:creator>ken horn</dc:creator>
		<pubDate>Wed, 14 May 2008 10:11:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.nobugs.org/blog/archives/2008/05/11/squawk-simple-queues-using-awk/#comment-33390</guid>
		<description>you can get away with this:
#! /bin/bash

(echo &quot;GET / HTTP/1.0&quot; ; echo &quot;&quot;) &#124; nc www.yahoo.com 80 &#124; awk &#039;
BEGIN{
  i=0
}
{
  print i++ &quot;&gt;  &quot; $0;
}&#039; &#124; head -20

alternatively if you need more processing, use &quot; instead or you can even process the current file and pipe it to awk if stdin is spare (i&#039;ve used ## comments to give a grep target), using back ticks to get extra nested shells is a neat trick too..</description>
		<content:encoded><![CDATA[<p>you can get away with this:<br />
#! /bin/bash</p>
<p>(echo &#8220;GET / HTTP/1.0&#8243; ; echo &#8220;&#8221;) | nc <a href="http://www.yahoo.com" rel="nofollow">http://www.yahoo.com</a> 80 | awk &#8216;<br />
BEGIN{<br />
  i=0<br />
}<br />
{<br />
  print i++ &#8220;&gt;  &#8221; $0;<br />
}&#8217; | head -20</p>
<p>alternatively if you need more processing, use &#8221; instead or you can even process the current file and pipe it to awk if stdin is spare (i&#8217;ve used ## comments to give a grep target), using back ticks to get extra nested shells is a neat trick too..</p>
]]></content:encoded>
	</item>
</channel>
</rss>
