<?xml version="1.0" encoding="utf-8"?><!-- generator="wordpress/2.3.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Squawk (simple queues using awk)</title>
	<link>http://www.nobugs.org/blog/archives/2008/05/11/squawk-simple-queues-using-awk/</link>
	<description>Thoughts of a software engineer</description>
	<pubDate>Thu, 28 Aug 2008 05:12:01 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
		<item>
		<title>By: Andrew</title>
		<link>http://www.nobugs.org/blog/archives/2008/05/11/squawk-simple-queues-using-awk/#comment-33393</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Wed, 14 May 2008 11:37:24 +0000</pubDate>
		<guid>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's stdin - its a two way conversation.  I use netcat -c "my_awk_command" for this.  But that means my awk command invocation would need to be escaped otherwise bash will expand things like '$0' 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't be in single quotes.

This page has some suggestions; I'll see if I can get it to work: http://www.gnu.org/manual/gawk/html_node/Quoting.html.  I didn't know that if you run something like this:

ls 'foo'"bar"  (no space between the quotes)

.. then ls receives a single argument - I'd always assumed it'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 - 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 - 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-33390</link>
		<dc:creator>ken horn</dc:creator>
		<pubDate>Wed, 14 May 2008 10:11:41 +0000</pubDate>
		<guid>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 "GET / HTTP/1.0" ; echo "") &#124; nc www.yahoo.com 80 &#124; awk '
BEGIN{
  i=0
}
{
  print i++ "&#62;  " $0;
}' &#124; head -20

alternatively if you need more processing, use " instead or you can even process the current file and pipe it to awk if stdin is spare (i'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>
