<?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>Computer Tips -Tech Info &#187; scripting</title>
	<atom:link href="http://www.averyjparker.com/category/scripting/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.averyjparker.com</link>
	<description>and Internet Security, Windows, Linux, Mac and other Tech Info from Avery J. Parker</description>
	<lastBuildDate>Mon, 21 Nov 2011 06:25:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Getting the current Date in Your Scripts</title>
		<link>http://www.averyjparker.com/2008/12/08/getting-the-current-date-in-your-scripts/</link>
		<comments>http://www.averyjparker.com/2008/12/08/getting-the-current-date-in-your-scripts/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 15:04:09 +0000</pubDate>
		<dc:creator>Avery</dc:creator>
				<category><![CDATA[scripting]]></category>
		<category><![CDATA[ading date to script]]></category>
		<category><![CDATA[date stamp]]></category>
		<category><![CDATA[shell scripting]]></category>

		<guid isPermaLink="false">http://www.averyjparker.com/?p=1673</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
	float:left;
	position: fixed;
	top: 60%;
	left: 70px;
}
#leftcontainerBox .buttons {
	float:left;
	clear:both;
	margin:4px 4px 4px 4px;
	padding-bottom:2px;
}
#bottomcontainerBox {
	width: 50%;
	padding-top: 1px;
}
#bottomcontainerBox .buttons {
	float: left;
	margin: 4px 4px 4px 4px;
}
</style>
I LIKE stamping things with the date, whether it&#8217;s a status report email or filename. (Like say I&#8217;ve downloaded todays news in Spanish, it really seems to make sense to tag it as spanish_news_12_8_08.mp3 instead of just spanish_news.mp3 doesn&#8217;t it?) Okay, so this is something I do in a lot of my shell scripts. Here&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
	float:left;
	position: fixed;
	top: 60%;
	left: 70px;
}
#leftcontainerBox .buttons {
	float:left;
	clear:both;
	margin:4px 4px 4px 4px;
	padding-bottom:2px;
}
#bottomcontainerBox {
	width: 50%;
	padding-top: 1px;
}
#bottomcontainerBox .buttons {
	float: left;
	margin: 4px 4px 4px 4px;
}
</style>

<!-- google_ad_section_start -->
<!--INFOLINKS_ON-->
<p><p>I LIKE stamping things with the date, whether it&#8217;s a status report email or filename.  (Like say I&#8217;ve downloaded todays news in Spanish, it really seems to make sense to tag it as spanish_news_12_8_08.mp3 instead of just spanish_news.mp3 doesn&#8217;t it?)</p>
<p>Okay, so this is something I do in a lot of my shell scripts.  Here&#8217;s some code to play with.</p>
<p><span id="more-1673"></span></p>
<p>Thankfully, linux has a great (and flexible) date command&#8230;</p>
<p>In the top part of your script just assign the variable date as such:</p>
<p>date=`date +%b%d%Y`</p>
<p>this uses the date command with the following format: Dec082008</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-5003751123450346";
google_ad_slot = "6558276326";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>Of course, there are other ways to format it &#8211; like  date +%F which gives you 2008-12-08</p>
<p>As you&#8217;re seeing the +and then %letter formats the date.  There are MANY different ways to format the date, in fact, if you just want the month, or day of week, that&#8217;s possible too.  you might want to consult the manual page for date to see all the choices.</p>
<p>So&#8230; from the console type man date</p>
<p>now, you can have the date or time stamp you want in any of your shell scripts.</p>

<!--INFOLINKS_OFF-->
<!-- google_ad_section_end -->
<img src="http://www.averyjparker.com/?ak_action=api_record_view&id=1673&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.averyjparker.com/2008/12/08/getting-the-current-date-in-your-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting rm to mp3</title>
		<link>http://www.averyjparker.com/2008/09/29/converting-rm-to-mp3/</link>
		<comments>http://www.averyjparker.com/2008/09/29/converting-rm-to-mp3/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 16:45:31 +0000</pubDate>
		<dc:creator>Avery</dc:creator>
				<category><![CDATA[Linux Software]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[mencoder]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[mplayer]]></category>
		<category><![CDATA[rm]]></category>

		<guid isPermaLink="false">http://www.averyjparker.com/?p=1643</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
	float:left;
	position: fixed;
	top: 60%;
	left: 70px;
}
#leftcontainerBox .buttons {
	float:left;
	clear:both;
	margin:4px 4px 4px 4px;
	padding-bottom:2px;
}
#bottomcontainerBox {
	width: 50%;
	padding-top: 1px;
}
#bottomcontainerBox .buttons {
	float: left;
	margin: 4px 4px 4px 4px;
}
</style>
Recently I&#8217;ve run across a realmedia stream that I really want to convert to mp3 (mainly because my portable player can&#8217;t read rm files. I&#8217;ll talk about capturing rm streams in another post, but this one is going to talk about converting from rm to mp3. For starters, it&#8217;s possible to use mencoder for this [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
	float:left;
	position: fixed;
	top: 60%;
	left: 70px;
}
#leftcontainerBox .buttons {
	float:left;
	clear:both;
	margin:4px 4px 4px 4px;
	padding-bottom:2px;
}
#bottomcontainerBox {
	width: 50%;
	padding-top: 1px;
}
#bottomcontainerBox .buttons {
	float: left;
	margin: 4px 4px 4px 4px;
}
</style>

<!-- google_ad_section_start -->
<!--INFOLINKS_ON-->
<p><p>Recently I&#8217;ve run across a realmedia stream that I really want to convert to mp3 (mainly because my portable player can&#8217;t read rm files.  I&#8217;ll talk about capturing rm streams in another post, but this one is going to talk about converting from rm to mp3.</p>
<p>For starters, it&#8217;s possible to use mencoder for this as follows:</p>
<p><span id="more-1643"></span><br />
<script type="text/javascript"><!--
google_ad_client = "pub-5003751123450346";
google_ad_slot = "6855210186";
google_ad_width = 468;
google_ad_height = 15;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>mencoder input_file.rm -ovc frameno -oac mp3lame -of rawaudio -lameopts cbr:br=128 -o output_file.mp3</p>
<p>This failed for me with an error that video was not optional.  Rather than trying to figure out how to make mencoder deal with an audio only rm&#8230; I looked for another way around it.<br />
So, &#8230;if you want another way to approach it, try this&#8230;</p>
<p>This makes use of mplayer to dump the audio to wav and then lame to encode to mp3</p>
<p>mplayer -ao pcm:file=audiodump.wav myrealmediafile.rm<br />
lame -h -v -b 128 audiodump.wav finalemp3file.mp3</p>
<p>The -b rate in the lame command sets the minimum bitrate &#8211; if you&#8217;re converting audio and you know your device can deal with variable bit rates you could drop that to 32.  (That&#8217;s what I did&#8230;)</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-5003751123450346";
google_ad_slot = "6558276326";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>

<!--INFOLINKS_OFF-->
<!-- google_ad_section_end -->
<img src="http://www.averyjparker.com/?ak_action=api_record_view&id=1643&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.averyjparker.com/2008/09/29/converting-rm-to-mp3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SED can make some things SO much easier</title>
		<link>http://www.averyjparker.com/2008/05/19/sed-can-make-some-things-so-much-easier/</link>
		<comments>http://www.averyjparker.com/2008/05/19/sed-can-make-some-things-so-much-easier/#comments</comments>
		<pubDate>Mon, 19 May 2008 15:30:07 +0000</pubDate>
		<dc:creator>Avery</dc:creator>
				<category><![CDATA[scripting]]></category>
		<category><![CDATA[New Hanover]]></category>
		<category><![CDATA[north carolina]]></category>
		<category><![CDATA[North Carolina Genealogy]]></category>
		<category><![CDATA[SED]]></category>
		<category><![CDATA[SO]]></category>
		<category><![CDATA[TWICE]]></category>

		<guid isPermaLink="false">http://www.averyjparker.com/?p=1614</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
	float:left;
	position: fixed;
	top: 60%;
	left: 70px;
}
#leftcontainerBox .buttons {
	float:left;
	clear:both;
	margin:4px 4px 4px 4px;
	padding-bottom:2px;
}
#bottomcontainerBox {
	width: 50%;
	padding-top: 1px;
}
#bottomcontainerBox .buttons {
	float: left;
	margin: 4px 4px 4px 4px;
}
</style>
If you have a linux machine and haven&#8217;t ever made use of sed (stream editor) you&#8217;re missing out on a great automation utility. I&#8217;ve saved myself probably 20 hours of manual editing with about an hour of work TWICE today. Here&#8217;s how&#8230;. over on the North Carolina Genealogy site I was opening forums for each [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
	float:left;
	position: fixed;
	top: 60%;
	left: 70px;
}
#leftcontainerBox .buttons {
	float:left;
	clear:both;
	margin:4px 4px 4px 4px;
	padding-bottom:2px;
}
#bottomcontainerBox {
	width: 50%;
	padding-top: 1px;
}
#bottomcontainerBox .buttons {
	float: left;
	margin: 4px 4px 4px 4px;
}
</style>

<!-- google_ad_section_start -->
<!--INFOLINKS_ON-->
<p><p>If you have a linux machine and haven&#8217;t ever made use of sed (stream editor) you&#8217;re missing out on a great automation utility.  I&#8217;ve saved myself probably 20 hours of manual editing with about an hour of work TWICE today.  Here&#8217;s how&#8230;. over on the North Carolina Genealogy site I was opening forums for each county in the state of North Carolina (100 counties.)  Now, I could have gone through and typed out a description, slug (address) and name for each one, but that looked too tedious. So&#8230;</p>
<p><span id="more-1614"></span><br />
<script type="text/javascript"><!--
google_ad_client = "pub-5003751123450346";
google_ad_slot = "6855210186";
google_ad_width = 468;
google_ad_height = 15;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>I copied and pasted the list of counties to a text file (there was a carriage return after each) so I had one per line.  Then I made a second file which I used tr to convert from upper case to lower case (since I wanted lower case &#8220;slugs&#8221;)  I then went through and used sed to convert a space to an underscore.  Now, I could have done this by hand because the only county with a space in the name is New Hanover, but&#8230;. it was easy as the following&#8230;</p>
<p><code>cat county_lowercase.txt | sed 's/ /_/' > county_lowercase_nospace.txt<br />
</code></p>
<p>So, the next step was crafting the slugs&#8230;</p>
<p><code>cat county_lowercase_nospace.txt | sed 's/$/-county-nc-genealogy-queries/' > slugs.txt<br />
</code></p>
<p>I checked the forum list table for my forum software through phpmyadmin and it was a pretty simple structure, about 8 fields&#8230;. a unique id which I set to NULL in my database, forum name, description, slug, forum order, number of posts, number of topics&#8230;. I set the last two to 0 throughout (100 lines), the forum order I started a bit past the current forum order numbers that were listed in the current database and I copied and pasted from the textfile the slugs.</p>
<p>So, next I crafted the forum titles&#8230;.</p>
<p><code>cat county_list.txt | sed 's/$/ County, NC Genealogy Query Forum/' > forum_titles.txt<br />
</code></p>
<p>And of course, those get copied and pasted into the correct column.  By the way, the $ above tells sed to put the text at the end of each line so that the county name comes first.</p>
<p>Then the descriptions, again I cut and paste and things look good.  From the spreadsheet now I export to csv and import via phpmyadmin and check, lo and behold I now have 100 forums correctly added.</p>
<p>The other big thing though was a script I use to retrieve rss feeds.  Each page was to have one uniquely named that would be included via a php include call in the page.</p>
<p>So&#8230; again sed to the rescue.</p>
<p><code>#!/bin/bash<br />
for name in `cat county_lower_nospace.txt`;<br />
do<br />
cat template_gen.php | sed "s/template_search/$name+county%22+nc/" > "$name"_gen.php<br />
done</code></p>
<p>VERY easy and it worked like a charm&#8230;. 100 php scripts created, one for each county in &#8230;. 5 seconds?  Nice.</p>
<p>Finally to top things off, I used sed to make the links to insert in to the pages&#8230; again all 100.  So, it turned into a simple copy paste for each one.</p>
<p>Thanks sed.. I don&#8217;t know how else I could have done this that didn&#8217;t involve hours of menial/tedious editing.</p>
<p>For more information on some of the neat textfile tricks you can do with sed&#8230; <a href="http://www.nuclearblender.com/leftovers/howto/commandline-spellbook/" class="broken_link" rel="nofollow">take a look at this sed guide</a>.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-5003751123450346";
google_ad_slot = "6558276326";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>

<!--INFOLINKS_OFF-->
<!-- google_ad_section_end -->
<img src="http://www.averyjparker.com/?ak_action=api_record_view&id=1614&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.averyjparker.com/2008/05/19/sed-can-make-some-things-so-much-easier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

