<?xml version="1.0" encoding="utf-8"?>
        <?xml-stylesheet type="text/css" href="http://www.linuxevolution.org/styles/feed.css"?>
<rss version="2.0"
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:dc="http://purl.org/dc/elements/1.1/"
 xmlns:admin="http://webns.net/mvcb/"
 xmlns:atom="http://www.w3.org/2005/Atom"
>
<channel>
<title>Filed under: Scripts | Linux Evolution dot org and the NSLU2</title>
<atom:link href="http://linuxevolution.org/archives/scripts/index-rss.xml" rel="self" type="application/rss+xml" />
<link>http://linuxevolution.org</link>
<description></description>
<dc:language>en-us</dc:language>
<dc:creator>orvtech</dc:creator>
<dc:date>2010-12-26T18:58:30-05:00</dc:date>
<admin:generatorAgent rdf:resource="http://nanoblogger.sourceforge.net" />

<item>
<link>http://linuxevolution.org/archives/2010/06/09/shell_script_to_backup_nanoblogger_to_a_remote_server/index.html</link>
<guid isPermaLink="true">http://linuxevolution.org/archives/2010/06/09/shell_script_to_backup_nanoblogger_to_a_remote_server/index.html</guid>
<title>Shell script to backup NanoBlogger to a remote server </title>
<dc:date>2010-06-09T16:23:49-05:00</dc:date>
<dc:creator>orvtech</dc:creator>
<dc:subject> Scripts, Linux, nanoblogger</dc:subject>
<description><![CDATA[<p>This is a simple script that creates full backups of our NanoBlogger blog by compressing our DocumentRoot directory and upload it to a remote server via SCP.</p>

<p>Lets take a look at it:<br />
<pre>#!/bin/bash
BLOG_PATH="/path/to/the/directory/that/contains/your/blog.conf/"
BLOG_NAME="orvtech.com"
DATE=`date +%d%b%Y-h%Hm%M`
NO_BAKUP="cache/*"
SCP_SERVER="<your_server_here>"
SCP_USER="<your_ssh_login_here>"
SCP_PORT="22"

cd $BLOG_PATH
tar -czpsf ~/$BLOG_NAME-nanoblogger.$DATE.tar.gz --exclude "$NO_BAKUP" *
ls -lah  ~/$BLOG_NAME-nanoblogger.$DATE.tar.gz
scp -P$SCP_PORT ~/$BLOG_NAME-nanoblogger.$DATE.tar.gz $SCP_USER@$SCP_SERVER:~/</pre>
</p>
<br />
<p><i>
<b>Spanish version:</b> <a href="http://orvtech.com/howto/respaldar-nanoblogger/" rel="friend" hreflang="en">Respaldar NanoBlogger.</a>
</i></p>]]></description>

</item>
<item>
<link>http://linuxevolution.org/archives/2010/05/18/find_the_biggest_file_or_folder_inside_a_directory/index.html</link>
<guid isPermaLink="true">http://linuxevolution.org/archives/2010/05/18/find_the_biggest_file_or_folder_inside_a_directory/index.html</guid>
<title>Find the biggest file or folder inside a directory.</title>
<dc:date>2010-05-18T10:57:05-05:00</dc:date>
<dc:creator>orvtech</dc:creator>
<dc:subject> OneLiners, Scripts, NSLU2, Linux, iPhone</dc:subject>
<description><![CDATA[<p>
By using the `du` command we can find the biggest file or directory inside a folder. The next example shows how to list the 10 most biggest files and floders inside 'HOME'
</p>

<pre>du -a ~/ | sort -n -r | head -n 10</pre>

<br />

<p>
If we use the `find` command we can list the 10 biggest files inside a directory, even if they are inside sub-folders.
</p>

<pre>find ~/ -type f -exec ls -ls {} \; | awk '{print $6"\t"$9}' | sort -k1 -n -r | head -n 10</pre>]]></description>

</item>
<item>
<link>http://linuxevolution.org/archives/2010/04/21/web_interface_for_nanoblogger_add_entries/index.html</link>
<guid isPermaLink="true">http://linuxevolution.org/archives/2010/04/21/web_interface_for_nanoblogger_add_entries/index.html</guid>
<title>Web interface for NanoBlogger: Add entries.</title>
<dc:date>2010-04-21T15:55:50-05:00</dc:date>
<dc:creator>orvtech</dc:creator>
<dc:subject> Scripts, NSLU2, nanoblogger</dc:subject>
<description><![CDATA[<p>
Please bare in mind that this is a proof of concept (that works) but here it is a web interface that allows you to submit entries to NanoBlogger through a BASH CGI. The script is rather simple, it just takes the fields title, description and body then writes it to a text file, you can latter process it through a cronjob or just leave it there for then you get a chance parse it by nb.
</p>

<p>
For this we will be using 3 code segments, the first would be the HTML form that will allow us to enter the content and pass those values to the CGI besides those two we have a javascript segment that allow us to preview the actual article that we are submitting.

</p>

<p>
<b>The Form.</b><br />
In other to have a bit of eye-candy i decided to use the heather and cascade style sheet from the actual style i am using for NanoBlogger. I found that the easiest way was to create a file by running `nb -b /path/of/the/blog/ make-file nb_send_entry.txt`. This will create a template that we can use to add the form HTML inside the 'BODY' section.
</p>


<textarea  style="height: 140px"  class="bashcode">
<form name="nb_entrada_send" method="post" ACTION="http://orvtech.com/send_nb_entry.cgi"><table border="0" width="600">
<tr>
<td width="100px">Titulo:</td>
<td width="500px"><input type="text" size="60" maxlength="50" id="title" name="entrada_title" value="Enter Title Here"></td>
</tr>
<tr>
<td width="100px">Descripcion:</td>
<td width="500px"><input type="text" size="60" maxlength="100" id="description" name="entrada_description" value="Enter Description Here"></td>
</tr>
<tr>
<td colspan="2">Contenido:<br />
< textarea cols="75" rows="30" id="body" name="entrada_body">
HTML esta permitido.
</ textarea>
</td>
</tr>
<tr>
<td width="600" colspan="2">
<div align="center "style="margin: auto; align: center; width: 600px;">
<input type="button" name="preview" value="Vista Previa" onclick="return openPreview();" />
&nbsp;&nbsp;<input type=submit value="Enviar" />&nbsp;&nbsp;
<input type="reset" value="Cancelar" />
</div>
</td>
</tr>
</table></form></textarea>


<p>
The product of this code is a web page with the same look and feel that the blog has. Here is a sample from our Spanish site:
</p>
<div><img src="http://orvtech.com/images/entry_form_screensho1.png" /></div>
<p>
<b>The JavaScript.</b><br />
If you take a look at above source code we have a 'preview' button; this button calls the function openPreview. The idea of this function is to show how would the HTML that we are codding look using the current style. You can get a good idea on how would this entry look before you submit it. Here is the code:
</p>



<textarea  style="height: 140px"  class="bashcode">
<script language="JavaScript">
function openPreview()
{
features = 'width=800, height=600, toolbar=no, menubar=no, resizable=no, location=no, directories=no, status=no';
var popWin = window.open ('','Preview_Entry', features);

var popTitleText = popWin.document.getElementById("title");
var titleText = document.getElementById("title");
var popBodyText = popWin.document.getElementById("body");
var bodyText = document.getElementById("body");

popWin.document.writeln('<head><title>Submit an Entry | Linux y el NSLU2</title><link rel="stylesheet" href="/styles/nb_default.css" type="text/css" media="all" /><link rel="shortcut icon" href="/favicon.ico" /></head><body> <div class="border"> <div class="container">  <div id="topmenu">  <ul>  <li><a href="/index.html" title="Inicio"><span>Inicio</span></a></li>  <li><a href="/gallery.html" title="Galería"><span>Galería</span></a></li>  <li><a href="/archives/scripts/index.html" title="BASH Scripts"><span>Scripts</span></a></li>  <li><a href="/articles/el_nslu2/" title="El NSLU2"><span>El NSLU2</span></a></li> <li><a href="/archives/scripts/index.html" title="Linux"><span>Linux</span></a></li> <li><a href="http://orvtech.com/index.html" title="orvtech.com in english"><span>In English</span></a></li>  </ul>  </div> <div id="header"></div><div class="container"><div class="archives"><div class="blogbody"> <h3 class="title">' + titleText.value + '</h3>' + bodyText.value + '</div></div></div></div></div></body>');

popTitleText.value = titleText.value;
popWin.document.close();
}
</script></textarea>



<p>
As you can see we are defining a new window and opening it with the content we entered on the form, it uses the nb_default.css. Most of the customizations can be done on in popWin.document.writeln in case you want to adapt it to your blog.
Remember that this is a proof of concept and that it can still be improved, perhaps we can latter make it to read the blog.conf file. Here is a screenshot of how it looks. 
</p>
<div><img src="http://orvtech.com/images/entry_form_screensho1.png" /></div>

<p>
<b>All you need is BASH.</b><br />
A CGI codded in bash to create the new entry for the blog. Here is the source code of send_nb_entry.cgi
</p>



<textarea  style="height: 140px"  class="bashcode">

#!/bin/bash

echo "Content-type: text/html"
echo -e "Status: 200 \n"
echo -e "<html><head><meta http-equiv=\"refresh\" content=\"2;url=http://orvtech.com\"></head><body><p>ENTRY ACCEPTED IN FOR QUEUE</p></body></html>"

DRAFT_ENTRY_DIRECTORY="/tmp"
POST_DATA=$(</dev/stdin)
TEMP_FILE="/tmp/nb_cgi_send_nb_entry.tmp"

nb_entrada_title=`echo $POST_DATA | sed -n 's/^.*entrada_title=\([^&]*\).*$/\1/p' | sed -e 's/%20/ /g'| sed 's/+/ /g'| sed 's/\%0[dD]//g' | awk '/%/{while(match($0,/\%[0-9a-fA-F][0-9a-fA-F]/)) {$0=substr($0,1,RSTART-1)sprintf("%c",0+("0x"substr($0,RSTART+1,2)))substr($0,RSTART+3);}}{print}'`
nb_entrada_description=`echo $POST_DATA | sed -n 's/^.*entrada_description=\([^&]*\).*$/\1/p' | sed -e 's/%20/ /g'| sed 's/+/ /g'| sed 's/\%0[dD]//g' | awk '/%/{while(match($0,/\%[0-9a-fA-F][0-9a-fA-F]/)) {$0=substr($0,1,RSTART-1)sprintf("%c",0+("0x"substr($0,RSTART+1,2)))substr($0,RSTART+3);}}{print}'`
name_entrada_tmp=`date +%Y-%m-%dT%H_%M_%S.tmp`
echo "TITLE: $nb_entrada_title" > $TEMP_FILE
echo "AUTHOR:" >> $TEMP_FILE
echo "DATE:" >> $TEMP_FILE
echo "DESC: $nb_entrada_description" >> $TEMP_FILE
echo "FORMAT: raw" >> $TEMP_FILE
echo "-----" >> $TEMP_FILE
echo "BODY:" >> $TEMP_FILE

echo $POST_DATA | sed -n 's/^.*entrada_body=\([^&]*\).*$/\1/p' | sed -e 's/%20/ /g'| sed 's/+/ /g'| sed 's/\%0[dD]//g' |\
   awk '/%/{while(match($0,/\%[0-9a-fA-F][0-9a-fA-F]/))\
       {$0=substr($0,1,RSTART-1)sprintf("%c",0+("0x"substr(\
       	      $0,RSTART+1,2)))substr($0,RSTART+3);}}{print}' >> $TEMP_FILE

	      echo "END-----" >> $TEMP_FILE
	      mv `echo -e $TEMP_FILE` `echo -e $DRAFT_ENTRY_DIRECTORY/$name_entrada_tmp`</textarea>




<p>
We can latter import the file defined by $DRAFT_ENTRY_DIRECTORY/$name_entrada_tmp issuing the command:
</p>


<textarea  style="height: 14px"  class="bashcode">
nb -b /path/to/your/blog import entry /tmp/2010-03-02T15_02_01.tmp</textarea>


<p>
This will add the entry to our blog. I though about automating this in the CGI but at this point i prefer to create a central control panel and keep things separated.
</p>
<br /><br />
<p><i>
<b>Spanish version:</b> <a href="http://orvtech.com/archives/2010/04/06/interfaz_web_para_agregar_entradas_a_nanoblogger/index.html">Interfaz web para agregar entradas a NanoBlogger.</a>
</i></p><br />]]></description>

</item>
<item>
<link>http://linuxevolution.org/archives/2010/04/21/znc_irc_bouncer_start_up_script/index.html</link>
<guid isPermaLink="true">http://linuxevolution.org/archives/2010/04/21/znc_irc_bouncer_start_up_script/index.html</guid>
<title>ZNC IRC Bouncer start up script.</title>
<dc:date>2010-04-21T12:52:16-05:00</dc:date>
<dc:creator>orvtech</dc:creator>
<dc:subject> Scripts, IRC, NSLU2, Linux</dc:subject>
<description><![CDATA[<p>
A few weeks a go I published an article about how to have push notifications to your iPhone from an IRC channel events. After installing and configuring ZNC I was a bit disappointed that it didn't had a start up script so I decided to write one. 
</p>
<p>
This script allows you to start, stop, reload the configuration and restart the service. lets take a look at /etc/init.d/zncd
</p>
<textarea class="bashcode"> 
#!/bin/bash
 
 ZNC_FOLDER="/usr/bin"
 ZNC_OWNR="your_user_here"
 
 if [ ! -f $ZNC_FOLDER/znc -o ! -d $ZNC_FOLDER ]
 then
 echo "ZNC startup: cannot start, it appears that it is not installed"
 exit 1
 fi
 
 case "$1" in
 start)
 echo -n "Starting ZNC: "
 su - $ZNC_OWNR -c "$ZNC_FOLDER/znc"
 touch /var/lock/subsys/ZNC
 echo "OK"
 ;;
 stop)
 echo -n "Shutdown ZNC: "
 kill -9 `ps -C znc | awk '{print $1}' | grep ^[0-9]`
 rm -f /var/lock/subsys/ZNC
 echo "OK"
 ;;
 reload)
 echo -n "Reloading ZNC:"
 kill -HUP `ps -C znc | awk '{print $1}' | grep ^[0-9]`
 echo "OK"
 ;;
 status)
 if ps -C znc > /dev/null
 then 
 echo "ZNC Bouncer is running"
 else 
 echo "ZNC Bouncer is not running"
 fi
 ;;
 restart)
 $0 stop
 sleep 2
 $0 start
 ;;
 *)
 echo "Usage: $0 start|stop|restart|reload|status"
 exit 1
 esac
 exit 0</textarea> 
<br /><p>
If your NSLU2 is running gentoo you could add it to the default run level like this:
</p>
<textarea style="height: 18px" class="bashcode"> 
rc-update add zncd default</textarea>
<br /><p>
The output should be something like this:
</p>
<textarea style="height: 18px" class="bashcode"> * zncd added to runlevel default</textarea> 
<br />
<p><i>
<b>Spanish version:</b> <a href="http://orvtech.com/general/script-de-arranque-para-znc-bouncer/" hreflang="es" rel="friend">script de arranque para ZNC bouncer.</a>
</i></p>]]></description>

</item>
<item>
<link>http://linuxevolution.org/archives/2010/04/11/bluetooh_audio_through_the_nslu2/index.html</link>
<guid isPermaLink="true">http://linuxevolution.org/archives/2010/04/11/bluetooh_audio_through_the_nslu2/index.html</guid>
<title>Bluetooh Audio Through the NSLU2.  </title>
<dc:date>2010-04-11T19:11:00-05:00</dc:date>
<dc:creator>orvtech</dc:creator>
<dc:subject> Scripts, NSLU2, Linux</dc:subject>
<description><![CDATA[
<p>
<a href="http://twitter.com/POTUSCamacho" rev="Original author of this guide">@POTUSCamacho</a> has an interesting article about how to use the NSLU2 in combination with a USB bluetooth adapter as an audio server. POTUSCamacho explains how to do it with a mono audio adapter but clarifies that it should be possible to do it using a stereo adapter.
</p>

<p>Lets take a look at this interesting howto:</p>

<blockquote cite="http://potuscamacho-industries.blogspot.com/2010/04/linksys-nslu2-utilizing-bluetooth-audio.html">

<p>Once you have installed Ubuntu, log in and update your packages:
</p>
<textarea style="height: 18px"  class="bashcode">
sudo -i apt-get update</textarea>
<p>
Then install the following packages:
</p>
<textarea style="height: 35px" class="bashcode">
sudo -i apt-get install linux-sound-base bluetooth bluez bluez-alsa bluez-btsco bluez-compat bluez-utils python python-bluez vlc</textarea>
<p><i>
Note: I do alot of other development stuff on my unit. I may have left off something, and if so let me know if you try it and it doesn't work.
</i><br />

Now that the needed packages are installed, an .asoundrc needs to be created in your user home directory. An example:
</p>
<textarea style="height: 50px" class="bashcode">
pcm.bluetooth {
type bluetooth
device 00:00:00:00:00:00
}</textarea>
<p>
Edit the device section with the MAC address of your bluetooth headset. To find this, issue a reset of the bluetooth adapter by issuing the command:
</p>
<textarea style="height: 18px" class="bashcode">
hciconfig hci0 reset</textarea>
<p>
Then place your headset in pairing mode and issue the following command:
</p>
<textarea style="height: 18px"  class="bashcode">
sdptool browse</textarea>
<p>
Now copy the following python script into a file named pair.py:
</p>
<textarea style="height: 480px" class="bashcode">
#!/usr/bin/python

import gobject

import sys
import dbus
import dbus.service
import dbus.mainloop.glib

class Rejected(dbus.DBusException):
_dbus_error_name = "org.bluez.Error.Rejected"

class Agent(dbus.service.Object):
exit_on_release = True

def set_exit_on_release(self, exit_on_release):
self.exit_on_release = exit_on_release

@dbus.service.method("org.bluez.Agent",
in_signature="", out_signature="")
def Release(self):
print "Release"
if self.exit_on_release:
mainloop.quit()

@dbus.service.method("org.bluez.Agent",
in_signature="os", out_signature="")
def Authorize(self, device, uuid):
print "Authorize (%s, %s)" % (device, uuid)
authorize = raw_input("Authorize connection (yes/no): ")
if (authorize == "yes"):
return
raise Rejected("Connection rejected by user")

@dbus.service.method("org.bluez.Agent",
in_signature="o", out_signature="s")
def RequestPinCode(self, device):
print "RequestPinCode (%s)" % (device)
return raw_input("Enter PIN Code: ")

@dbus.service.method("org.bluez.Agent",
in_signature="o", out_signature="u")
def RequestPasskey(self, device):
print "RequestPasskey (%s)" % (device)
passkey = raw_input("Enter passkey: ")
return dbus.UInt32(passkey)

@dbus.service.method("org.bluez.Agent",
in_signature="ou", out_signature="")
def DisplayPasskey(self, device, passkey):
print "DisplayPasskey (%s, %d)" % (device, passkey)

@dbus.service.method("org.bluez.Agent",
in_signature="ou", out_signature="")
def RequestConfirmation(self, device, passkey):
print "RequestConfirmation (%s, %d)" % (device, passkey)
confirm = raw_input("Confirm passkey (yes/no): ")
if (confirm == "yes"):
return
raise Rejected("Passkey doesn't match")

@dbus.service.method("org.bluez.Agent",
in_signature="s", out_signature="")
def ConfirmModeChange(self, mode):
print "ConfirmModeChange (%s)" % (mode)

@dbus.service.method("org.bluez.Agent",
in_signature="", out_signature="")
def Cancel(self):
print "Cancel"

def create_device_reply(device):
print "New device (%s)" % (device)
mainloop.quit()

def create_device_error(error):
print "Creating device failed: %s" % (error)
mainloop.quit()

if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object("org.bluez", "/"),
"org.bluez.Manager")

if len(sys.argv) > 1:
path = manager.FindAdapter(sys.argv[1])
else:
path = manager.DefaultAdapter()

adapter = dbus.Interface(bus.get_object("org.bluez", path),
"org.bluez.Adapter")

path = "/test/agent"
agent = Agent(bus, path)

mainloop = gobject.MainLoop()

if len(sys.argv) > 2:
if len(sys.argv) > 3:
device = adapter.FindDevice(sys.argv[2])
adapter.RemoveDevice(device)

agent.set_exit_on_release(False)
adapter.CreatePairedDevice(sys.argv[2], path, "DisplayYesNo",
reply_handler=create_device_reply,
error_handler=create_device_error)
else:
adapter.RegisterAgent(path, "DisplayYesNo")
print "Agent registered"

mainloop.run()

#adapter.UnregisterAgent(path)
#print "Agent unregistered"</textarea>

<p>
Now place your headset into pairing mode again and issue the follow command:
</p>
<textarea style="height: 18px" class="bashcode">sudo -i python pair.py hci0 00:00:00:00:00:00</textarea>

<p>
Once again replacing the address above with your headsets MAC.
The last step involves editing the vlcrc. To do this, issue the command:
</p>

<textarea style="height: 18px" class="bashcode">
pico .vlc/vlcrc
</textarea>

<p>
Scroll down and replace:
</p>

<textarea style="height: 18px" class="bashcode">
alsadev=(default soundcard) </textarea>

<p>To:</p>

<textarea style="height: 18px" class="bashcode">
alsadev=bluetooth</textarea>

<p>
If it does not exist then create it.
</p>

<p>
Now you should be ready to listen to audio. To listen to the audio from NASA TV's online video stream, issue the command:
</p>

<textarea style="height: 18px" class="bashcode">
cvlc --aout-rate 8000 --novideo http://www.nasa.gov/55644main_NASATV_Windows.asx</textarea>

<p>
If everything is working you should hear audio. Keep in mind that the sample rate needs to be 8000Hz since that is the sample rate the headset can handle.
</p>

<p>
To pair another headset, or to re-pair the current, the /var/lib/bluetooth/(your MAC)/linkkeys file must be deleted. It will regenerate once you have paired the devices. Also remember that the .asoundrc file must be edited to match a different headset as the MAC will be different.
</p></blockquote>

<p>
To find out more info about this article, please visit <a href="http://potuscamacho-industries.blogspot.com/2010/04/linksys-nslu2-utilizing-bluetooth-audio.html">POTUSCamacho Industries</a> blog.
</p>
<br />
<p><i>
<b>Spanish version:</b> <a href="http://orvtech.com/archives/2010/04/12/audio_via_bluetooh_desde_el_nslu2/index.html">Audio vía bluetooh desde el NSLU2.</a>
</i></p>]]></description>

</item>
<item>
<link>http://linuxevolution.org/archives/2010/03/26/a_bash_cgi_as_a_workaround_to__htaccess_files_on_lighttpd/index.html</link>
<guid isPermaLink="true">http://linuxevolution.org/archives/2010/03/26/a_bash_cgi_as_a_workaround_to__htaccess_files_on_lighttpd/index.html</guid>
<title>A BASH CGI as a workaround to .htaccess files on lighttpd</title>
<dc:date>2010-03-26T12:49:32-05:00</dc:date>
<dc:creator>orvtech</dc:creator>
<dc:subject> Scripts, NSLU2, Linux, nanoblogger, lighttp</dc:subject>
<description><![CDATA[<p>
As you might remember, in a previous post I explained how to maintain a permanent link which always points 
to the latest submission on your nanoblogger website. Since I decided to migrate from apache to lighttp I 
lost the ability to use .htacees files thus .htacees file based redirects do not work anymore.
</p>
<p>
<br /><b>The workaround.</b><br />

We will keep using the /latest url for the redirects the only thing is that we will use a CGI written in 
BASH to accomplish the redirect. The script will parse our RSS feed (rss.xml) to check which is the latest 
post and redirect to that url. The redirect is accomplished by sending the HTTP headers 'Location' and 
'Status'. Let's take a look at the script:
<br />
<i>latest.cgi</i><br />

<textarea style="height: 80px" class="bashcode">
#!/bin/bash
DocummentRoot="/var/www/linuxevolution.org/htdocs"
Latest=`cat $DocummentRoot/rss.xml | grep link | grep archives | head -n1 | sed -e :a -e 's/<[^>]*>//g;/</N;//ba'`
echo "Status: 302 Moved"
echo -e "Location: $Latest\n"</textarea>
</p>
<p>
Here we are sending the Status header to prevent search engines from associating more than one url to the 
same content (this will give us a lower score in some search engines' systems) and then we send the 
Location header to do the actual redirect.
</p>
<p>
<br /><b>Lighttp and CGIs.</b><br />

In other to execute this CGI we need to make some minor modifications to our VirtualHostost configuration. 
Lets add these two lines to it:
<br />

<textarea style="height: 26px" class="bashcode">
cgi.assign = ( ".cgi" => "/bin/bash" )
url.redirect =( "^/latest/(.*)" => "http://www.linuxevolution.org/latest.cgi")</textarea>


</p>
<p>
In the first line we are telling lighttpd to use /bin/bash to execute any *.cgi file (you can change this 
to anything like *.sh, *.bash). In the second line we redirect all requests to /latest/ to the url 
/latest.cgi. You can either use /latest.cgi or /latest/ for these urls in your signature at the forums; 
personally I like to use /latest/<name of the forum here> to keep track of where is my traffic coming from 
even if I don't get the HTTP referrer.
</p>
<br />
<p><i>
<b>Spanish version:</b> <a href="http://orvtech.com/howto/un-cgi-en-bash-para-mantener-tu-firma-al-dia-en-todos-los-foros-en-que-participas/" rel="friend" hreflang="es">Un CGI en BASH para mantener tu firma al dia en todos los foros en que participas.</a>
</i></p>]]></description>

</item>
<item>
<link>http://linuxevolution.org/archives/2010/03/19/from_picasaweb_albums_to_bbcode/index.html</link>
<guid isPermaLink="true">http://linuxevolution.org/archives/2010/03/19/from_picasaweb_albums_to_bbcode/index.html</guid>
<title>From Picasaweb Albums to BBCode</title>
<dc:date>2010-03-19T11:03:40-05:00</dc:date>
<dc:creator>orvtech</dc:creator>
<dc:subject> Scripts</dc:subject>
<description><![CDATA[<p>
This script has the same function as the <a href="http://linuxevolution.org/archives/2010/03/16/from_flickr_to_bbcode_script/index.html" title="Flickr2BBCode script">Flickr script</a>, it takes a Picasaweb album and gets the BBCode to allow you to share it on a forum, the urls that we are going to work with have the picasaweb.google.com/<user>/<album_name> structure, for example this URL: 
<br /><i>http://picasaweb.google.com/orvtech/Hdd</i>
</p>
<br />
<p>
Lets take a look at the code:<br />
<textarea  style="height: 140px"  class="bashcode">
#!/bin/bash
SIZE=400

echo $1 | \
curl -s `awk --field-separator=/ '{print "http://picasaweb.google.com/data/feed/api/user/"$4"/album/"$5}'` |\
sed -e 's/\"/\ /g' -e s/\'/\ /g |\
tr ' ' '\n' |\
grep  s72 |\
awk '{print "[url='$1'][img]"$0"[/img][/url]\n"}' |\
sed s/s72/s$SIZE/g
</textarea>
</p>
<br />
<p>
Lets name this script Picasa2BBCode.sh, we can execute it like this:<br />
<textarea  style="height: 17px"  class="bashcode">
sh Picasa2BBCode.sh http://picasaweb.google.com/orvtech/Hdd</textarea>
</p>
<br />
<p>
We can modify the constant SIZE in this script, it can take the values 72px, 144px, 288px, 320px, 400px, 512px, 576px, 640px, 800px or 1024px but if the image is smaller than 800px we might have some problems. Running the script will produce an output like this:<br />

<textarea  style="height: 130px"  class="bashcode">
[url=http://picasaweb.google.com/orvtech/Hdd#][img]http://lh6.ggpht.com/_WwtoUQV8M_8/S5kBtkqKAdI/AAAAAAAAPbM/I0LCPdB-qpQ/s400/IMG_7457.JPG[/img][/url]

[url=http://picasaweb.google.com/orvtech/Hdd#][img]http://lh3.ggpht.com/_WwtoUQV8M_8/S5kBtwXW08I/AAAAAAAAPbQ/Y636HBHOxEo/s400/IMG_7458.JPG[/img][/url]

[url=http://picasaweb.google.com/orvtech/Hdd#][img]http://lh5.ggpht.com/_WwtoUQV8M_8/S5kBtzPQLrI/AAAAAAAAPbU/ZOWfnh4uGuA/s400/IMG_7459.JPG[/img][/url]

[url=http://picasaweb.google.com/orvtech/Hdd#][img]http://lh5.ggpht.com/_WwtoUQV8M_8/S5kBuJEzUPI/AAAAAAAAPbY/qxTGuFR_EbA/s400/IMG_7461.JPG[/img][/url]

[url=http://picasaweb.google.com/orvtech/Hdd#][img]http://lh3.ggpht.com/_WwtoUQV8M_8/S5kBupiHjqI/AAAAAAAAPbc/FShn8ryEr54/s400/IMG_7462.JPG[/img][/url]

[url=http://picasaweb.google.com/orvtech/Hdd#][img]http://lh5.ggpht.com/_WwtoUQV8M_8/S5kCW9ags7I/AAAAAAAAPbw/wFYET5XlgkQ/s400/IMG_7463.JPG[/img][/url]

[url=http://picasaweb.google.com/orvtech/Hdd#][img]http://lh5.ggpht.com/_WwtoUQV8M_8/S5kCXA_XujI/AAAAAAAAPb0/WDc3N1tLDCw/s400/IMG_7464.JPG[/img][/url]

[url=http://picasaweb.google.com/orvtech/Hdd#][img]http://lh4.ggpht.com/_WwtoUQV8M_8/S5kCXDnyhkI/AAAAAAAAPb4/SWuagR3LA8c/s400/IMG_7465.JPG[/img][/url]

[url=http://picasaweb.google.com/orvtech/Hdd#][img]http://lh5.ggpht.com/_WwtoUQV8M_8/S5kCXTt6vaI/AAAAAAAAPb8/i1RmMrL5slg/s400/IMG_7466.JPG[/img][/url]

[url=http://picasaweb.google.com/orvtech/Hdd#][img]http://lh5.ggpht.com/_WwtoUQV8M_8/S5kCX8hUk-I/AAAAAAAAPcA/YzOe_0bO0Jw/s400/IMG_7468.JPG[/img][/url]
...</textarea>
</p>
<br />
<p><i>
<b>Spanish version:</b> <a href="http://orvtech.com/howto/de-picasa-a-bbcode/" rel="friend" hreflant="es">De Picasa a BBCode.</a>
</i></p>]]></description>

</item>
<item>
<link>http://linuxevolution.org/archives/2010/03/16/from_flickr_to_bbcode_script/index.html</link>
<guid isPermaLink="true">http://linuxevolution.org/archives/2010/03/16/from_flickr_to_bbcode_script/index.html</guid>
<title>From flickr to bbcode script</title>
<dc:date>2010-03-16T10:27:06-05:00</dc:date>
<dc:creator>orvtech</dc:creator>
<dc:subject> Scripts</dc:subject>
<description><![CDATA[<p>
As you know I participate a lot in internet forums and most of these use <a href="http://en.wikipedia.org/wiki/BBCode">BBCode</a> to let us pulish photos, youtube videos,
links, etc. Since I like to share photos and dont want to copy the url of each image on a set of 60 or more images on flickr
I decided to automate this and wrote a simple script that will generate the <a href="http://en.wikipedia.org/wiki/BBCode">BBCode</a> from a flickr set url.
</p>
<p>
Lets take a look at this script, lets call it flickr2bbcode.sh
</p>
<textarea  style="height: 60px"  class="bashcode">
#!/bin/bash
curl -s $1 | tr ' ' '\n' | grep '_s.jpg' |\
sed "s/\"/\ /g" |sed -e 's/_s\.jpg/\.jpg/g'|\
awk '{print "[url='$1'][img]"$2"[/img][/url]\n"}'</textarea>
<p>
If you want to run this script you will need to pass the url of the set of photos that you want to
publish, for example <i>http://www.flickr.com/photos/tatadbb/sets/72157606893687387/</i> so your command line will look like this:
</p>
<textarea  style="height: 20px"  class="bashcode">
sh flickr2bbcode.sh http://www.flickr.com/photos/tatadbb/sets/72157606893687387/
</textarea>
<p>
The out put of this command would be something like this:
</p>
<textarea  style="height: 130px"  class="bashcode">
[url=http://www.flickr.com/photos/tatadbb/sets/72157606893687387/][img]http://farm4.static.flickr.com/3075/2787828382_10ea6d0924.jpg[/img][/url]

[url=http://www.flickr.com/photos/tatadbb/sets/72157606893687387/][img]http://farm4.static.flickr.com/3017/2806875776_fa4f208409.jpg[/img][/url]

[url=http://www.flickr.com/photos/tatadbb/sets/72157606893687387/][img]http://farm4.static.flickr.com/3145/2817776689_ffc218e9e8.jpg[/img][/url]

[url=http://www.flickr.com/photos/tatadbb/sets/72157606893687387/][img]http://farm4.static.flickr.com/3329/3280872113_722ff06df8.jpg[/img][/url]

[url=http://www.flickr.com/photos/tatadbb/sets/72157606893687387/][img]http://farm4.static.flickr.com/3636/3280920431_f257aaec90.jpg[/img][/url]

...</textarea>

<br />
<p><i>
<b>Spanish version:</b> <a href="http://orvtech.com/howto/cgi-para-obtener-el-bbcode-de-flickr-y-picasaweb-hecha-en-bash/" rel="friend" hreflang="es">De Flickr a BBCode.</a>
</i></p>]]></description>

</item>
<item>
<link>http://linuxevolution.org/archives/2010/03/09/latest_url_for_all_your_nanoblogger_websites/index.html</link>
<guid isPermaLink="true">http://linuxevolution.org/archives/2010/03/09/latest_url_for_all_your_nanoblogger_websites/index.html</guid>
<title>Latest URL for all your NanoBlogger websites.</title>
<dc:date>2010-03-09T20:39:46-05:00</dc:date>
<dc:creator>orvtech</dc:creator>
<dc:subject> Scripts</dc:subject>
<description><![CDATA[<p>
So I kinda participate a lot in these community forums and I wanted to keep my signature linking to my latest post without having to change my signature on all of them each time, I created this script that will get the latest entry submitted and will create a .htaccess file redirecting requests to a previous determined directory to the latest entry.
</p>
<textarea  style="height: 95px"  class="bashcode">
#!/bin/bash
DocummentRoot="/var/www/linuxevolution.org/htdocs /var/www/orvtech.com/htdocs"

for virtualhost in $DocummentRoot
do cat $virtualhost/rss.xml  | grep link | grep archives |\
head -n1 | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' |\
awk '{print "RewriteEngine on\nRewriteRule (.*) "$0" [R=301,L]"}' > $virtualhost/latest/.htaccess
done</textarea>
<br />
<p>In order for this to work you will have to create the 'latest' directory inside your root directory or modify the script.</p>
<p>In my case I have 2 websites, and this script keeps the '/latest/' directory pointing to the latest entry on each of them (<a href="http://www.linuxevolution.org/latest/">http://linuxevolution.org/latest</a> and <a href="http://orvtech.com/latest/" rel="nofollow">http://orvtech.com/latest</a> the spanish version of this website)</p>
<br />
<p><i>
<b>Spanish version:</b> <a href="http://orvtech.com/howto/un-cgi-en-bash-para-mantener-tu-firma-al-dia-en-todos-los-foros-en-que-participas/" rel="friend" hreflang="es">Un CGI en BASH para mantener tu firma al dia en todos los foros en que participas.</a>
</i></p>]]></description>

</item>
<item>
<link>http://linuxevolution.org/archives/2010/02/23/find_ms-dos_formatted_files/index.html</link>
<guid isPermaLink="true">http://linuxevolution.org/archives/2010/02/23/find_ms-dos_formatted_files/index.html</guid>
<title>Find MS-DOS Formatted Files. </title>
<dc:date>2010-02-23T11:18:30-05:00</dc:date>
<dc:creator>orvtech</dc:creator>
<dc:subject> Scripts, Linux</dc:subject>
<description><![CDATA[<p>I recently came across a problem where I had a bunch of perl scripts that were modified under MS Windows and had the MS-DOS format. I found a bunch of errors on the crond logs since these scripts were being called by a crontab. Long story short I had to find all these scripts so I used this recursive grep inside the directory where this files were uploaded.</p>

<textarea style="height: 35px" class="bashcode" readonly wrap="off">grep -IUl --color '^M' -R ./*</textarea>
<br />
<p>The output of this command will generate a list of files that are formatted as DOS files.
<a class="DiggThisButton">('<img src="http://digg.com/img/diggThisCompact.png" height="18" width="120" alt="DiggThis" />’)</a>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></p>
<br />
<p><i>
<b>Spanish version:</b> <a href="http://orvtech.com/howto/encontrar-archivos-con-formato-ms-dos/" rel="friend" hreflang="es">Encontrar archivos con formato MS-DOS.<a>
</i></p>]]></description>

</item>
</channel>
</rss>

