<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: shell code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 27 Jul 2008 09:15:14 GMT</pubDate>
    <description>DZone Snippets: shell code</description>
    <item>
      <title>simple init.d script for django using fastcgi</title>
      <link>http://snippets.dzone.com/posts/show/5775</link>
      <description>&lt;code&gt;&lt;br /&gt;#!/bin/sh&lt;br /&gt;#&lt;br /&gt;# chkconfig:	345 85 15&lt;br /&gt;# description:	FastCGI server for Django&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# Source function library&lt;br /&gt;. /etc/rc.d/init.d/functions&lt;br /&gt;&lt;br /&gt;# Source networking configuration.&lt;br /&gt;. /etc/sysconfig/network&lt;br /&gt;&lt;br /&gt;# Check that networking is up.&lt;br /&gt;[ "${NETWORKING}" = "no" ] &amp;&amp; exit 0&lt;br /&gt;&lt;br /&gt;PROJ=myproject					# Django project name&lt;br /&gt;PROJSPATH=/home/user/www			# The folder Django project is in&lt;br /&gt;SOCKSPATH=/tmp					# Where you put UNIX socket file&lt;br /&gt;PIDSPATH=/var/run				# Where you put .pid file&lt;br /&gt;RUNAS=root					# Set a different user to run the FastCGI server&lt;br /&gt;&lt;br /&gt;SRVNAME=fcgi-$PROJ				# Process name&lt;br /&gt;&lt;br /&gt;# Maximum requests for a child to service before expiring&lt;br /&gt;#MAXREQ=&lt;br /&gt;# Spawning method - prefork or threaded&lt;br /&gt;#METHOD=&lt;br /&gt;# Maximum number of children to have idle&lt;br /&gt;#MAXSPARE=&lt;br /&gt;# Minimum number of children to have idle&lt;br /&gt;#MINSPARE=&lt;br /&gt;# Maximum number of children to spawn&lt;br /&gt;#MAXCHILDREN=&lt;br /&gt;&lt;br /&gt;start () {&lt;br /&gt;	# Check if the service is already running?&lt;br /&gt;	if [ ! -f $PIDSPATH/$SRVNAME.pid ]; then&lt;br /&gt;		echo -n $"Starting $SRVNAME..."&lt;br /&gt;		daemon --user $RUNAS $PROJSPATH/$PROJ/manage.py runfcgi pidfile=$PIDSPATH/$SRVNAME.pid \&lt;br /&gt;			socket=$SOCKSPATH/$SRVNAME.sock \&lt;br /&gt;			${MAXREQ:+maxrequests=$MAXREQ} \&lt;br /&gt;			${METHOD:+method=$METHOD} \&lt;br /&gt;			${MAXSPARE:+maxspare=$MAXSPARE} \&lt;br /&gt;			${MINSPARE:+minspare=$MINSPARE} \&lt;br /&gt;			${MAXCHILDREN:+maxchildren=$MAXCHILDREN} \&lt;br /&gt;			${DAEMONISE:+damonize=True}&lt;br /&gt;		echo&lt;br /&gt;		chmod 777 $SOCKSPATH/$SRVNAME.sock&lt;br /&gt;		RETVAL=$?&lt;br /&gt;	else&lt;br /&gt;		echo $"$SRVNAME is already running."&lt;br /&gt;	fi&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;stop() {&lt;br /&gt;	# Stop daemons.&lt;br /&gt;	if [ -f $PIDSPATH/$SRVNAME.pid ]; then&lt;br /&gt;		echo -n $"Stopping $SRVNAME..."&lt;br /&gt;		killproc -p "$PIDSPATH/$SRVNAME.pid" -d 60 $SRVNAME&lt;br /&gt;		echo&lt;br /&gt;		# Delete pidfile only when Django was called successfully&lt;br /&gt;		if [ $? -eq 0 ]; then&lt;br /&gt;			rm -f $PIDSPATH/$SRVNAME.pid "$SRVNAME.pid"  &gt;/dev/null 2&gt;&amp;1&lt;br /&gt;		fi&lt;br /&gt;	else&lt;br /&gt;		echo $"$SRVNAME is NOT running."&lt;br /&gt;	fi&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;RETVAL=0&lt;br /&gt;&lt;br /&gt;case "$1" in&lt;br /&gt;	start)&lt;br /&gt;		start&lt;br /&gt;		;;&lt;br /&gt;	stop)&lt;br /&gt;		stop&lt;br /&gt;		;;&lt;br /&gt;	status)&lt;br /&gt;		status -p "$PIDSPATH/$SRVNAME.pid" $SRVNAME&lt;br /&gt;		RETVAL=$?&lt;br /&gt;		;;&lt;br /&gt;	restart)&lt;br /&gt;		stop&lt;br /&gt;		start&lt;br /&gt;		;;&lt;br /&gt;	*)&lt;br /&gt;		echo $"Usage: $0 {start|stop|restart|status}"&lt;br /&gt;		exit 3&lt;br /&gt;		;;&lt;br /&gt;esac&lt;br /&gt;&lt;br /&gt;exit $RETVAL&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 15 Jul 2008 23:01:13 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5775</guid>
      <author>stvnz (Steven)</author>
    </item>
    <item>
      <title>Detecting bluetooth devices with hcitool scan</title>
      <link>http://snippets.dzone.com/posts/show/5764</link>
      <description>A trivial Ruby script to store the bluetooth devices found with the shell command 'hcitool scan'.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/ruby&lt;br /&gt;&lt;br /&gt;#file: bt_scan.rb&lt;br /&gt;&lt;br /&gt;require 'rexml/document'&lt;br /&gt;include REXML&lt;br /&gt;&lt;br /&gt;while true&lt;br /&gt;  filein = File.new('bt_found.xml','r')&lt;br /&gt;  doc = Document.new(filein)&lt;br /&gt;  filein.close&lt;br /&gt;&lt;br /&gt;  fileout = File.new('bt_found.xml','w')&lt;br /&gt;&lt;br /&gt;  result = `hcitool scan`&lt;br /&gt;  found = result.split(/\n/) # retrieve each found device&lt;br /&gt;  found.delete_at(0)         # remove the item containing 'scanning ...'&lt;br /&gt;&lt;br /&gt;  found.each do |b|&lt;br /&gt;    node_found = Element.new('found')&lt;br /&gt;    p = b.split(/\t/) # retrieve device details&lt;br /&gt;    id = p[1]&lt;br /&gt;    name = p[2]&lt;br /&gt;    puts "name #{name} --- id #{id}"&lt;br /&gt;    node_id = Element.new('id')&lt;br /&gt;    node_name = Element.new('name')&lt;br /&gt;    node_date = Element.new('date')&lt;br /&gt;&lt;br /&gt;    node_id.text = id&lt;br /&gt;    node_name.text = name&lt;br /&gt;    node_date.text = Time.now&lt;br /&gt;&lt;br /&gt;    node_found &lt;&lt; node_id&lt;br /&gt;    node_found &lt;&lt; node_name&lt;br /&gt;    node_found &lt;&lt; node_date&lt;br /&gt;    doc.root &lt;&lt; node_found&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  fileout.puts doc&lt;br /&gt;  fileout.close&lt;br /&gt;  puts 'sleeping'&lt;br /&gt;  sleep 10 # during this time we can kill the script, &lt;br /&gt;           # otherwise we risk losing the contents of the xml file.&lt;br /&gt;  puts 'awake'&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Note: Shell commands don't really have much to do with Ruby, however if there is no easy to use bluetooth libraries then I will of course use what's available.</description>
      <pubDate>Sun, 13 Jul 2008 22:31:47 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5764</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Monitor disk usage with a simple Ruby script</title>
      <link>http://snippets.dzone.com/posts/show/5754</link>
      <description>&lt;code&gt;&lt;br /&gt;dev = 'sda1'&lt;br /&gt;report = `df -h`&lt;br /&gt;disk_remaining = report[/sda\w+\s+\d+?.?\dG\s+\d+?.?\dG\s+(\d+.?\d+?G)/,1]&lt;br /&gt;puts "running low on disk space (#{dev}: #{disk_remaining })" if disk_remaining.to_i &lt; 3&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 10 Jul 2008 12:40:28 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5754</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Inspect a website like a string in Ruby</title>
      <link>http://snippets.dzone.com/posts/show/5745</link>
      <description>Put the following function into your ~/.bash_login (or alternatives).&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;unset -f inspect_url&lt;br /&gt;&lt;br /&gt;function inspect_url() { &lt;br /&gt;   /usr/bin/curl -L -s --max-time 10 "${@}" | ruby -n -e 'p $_.to_s'&lt;br /&gt;   return 0&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;inspect_url http://www.ruby-forum.com&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 09 Jul 2008 21:13:48 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5745</guid>
      <author>ntk ()</author>
    </item>
    <item>
      <title>Play audio with a Ruby shell script</title>
      <link>http://snippets.dzone.com/posts/show/5744</link>
      <description>Play an ogg file from the command-line using the program ogg123 from the software package 'vorbis-tools'.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/ruby&lt;br /&gt;&lt;br /&gt;#file: ogg-play.rb&lt;br /&gt;&lt;br /&gt;`ogg123 #{ARGV[0]} &gt; /dev/null 2&gt;&amp;1`&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;e.g. &lt;br /&gt;&lt;code&gt;&lt;br /&gt;wget http://upload.wikimedia.org/wikipedia/en/4/4d/Elo_blue_sky.ogg&lt;br /&gt;./ogg-play.rb Elo_blue_sky.ogg&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 09 Jul 2008 19:15:45 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5744</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Compile &amp; install Nginx web server</title>
      <link>http://snippets.dzone.com/posts/show/5668</link>
      <description>Requirement on Mac OS X: &lt;a href="http://developer.apple.com/tools/xcode/index.html"&gt;Xcode&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# See:&lt;br /&gt;# - http://en.wikipedia.org/wiki/Nginx&lt;br /&gt;# - http://wiki.codemongers.com/NginxGettingStarted&lt;br /&gt;# - http://wiki.codemongers.com/NginxInstallOptions&lt;br /&gt;# - http://wiki.codemongers.com/NginxCommandLine&lt;br /&gt;# - http://wiki.codemongers.com/NginxConfiguration&lt;br /&gt;&lt;br /&gt;export PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin"&lt;br /&gt;&lt;br /&gt;mkdir -p ~/Desktop/Nginx&lt;br /&gt;cd ~/Desktop/Nginx&lt;br /&gt;&lt;br /&gt;curl -L -O http://sysoev.ru/nginx/nginx-0.7.2.tar.gz&lt;br /&gt;tar -xzf nginx-0.7.2.tar.gz&lt;br /&gt;&lt;br /&gt;curl -L -O http://downloads.sourceforge.net/pcre/pcre-7.7.tar.gz&lt;br /&gt;tar -xzf pcre-7.7.tar.gz&lt;br /&gt;&lt;br /&gt;cd ~/Desktop/Nginx/nginx-0.7.2&lt;br /&gt;./configure --help&lt;br /&gt;./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/sbin --with-debug --with-http_ssl_module --with-pcre=../pcre-7.7&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;which nginx&lt;br /&gt;otool -L /usr/local/sbin/nginx&lt;br /&gt;open /usr/local/nginx&lt;br /&gt;open -e /usr/local/nginx/conf/nginx.conf&lt;br /&gt;&lt;br /&gt;nginx -v&lt;br /&gt;nginx -V&lt;br /&gt;sudo nginx   # start server&lt;br /&gt;sudo nginx -t&lt;br /&gt;&lt;br /&gt;open http://localhost:80&lt;br /&gt;open http://localhost:80/50x.html&lt;br /&gt;&lt;br /&gt;sudo nano /usr/local/nginx/conf/nginx.conf   # editing ... server {  listen  8080; ... &lt;br /&gt;&lt;br /&gt;# reload configuration&lt;br /&gt;sudo kill -HUP `cat /usr/local/nginx/logs/nginx.pid`  &lt;br /&gt;&lt;br /&gt;# stop server&lt;br /&gt;sudo kill -15 $(ps -auxxx | egrep "[n]ginx.*master" | awk '{ print $2 }') 2&gt;/dev/null&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 18 Jun 2008 20:03:18 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5668</guid>
      <author>ntk ()</author>
    </item>
    <item>
      <title>Basic WEBrick setup for local web server</title>
      <link>http://snippets.dzone.com/posts/show/5659</link>
      <description>Put the following functions and aliases into your ~/.bash_login (or alternatives).&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;unset -f webrick_local&lt;br /&gt;&lt;br /&gt;function webrick_local() { &lt;br /&gt;&lt;br /&gt;   declare root_dir="${HOME}/Desktop/www"&lt;br /&gt;&lt;br /&gt;   /bin/mkdir -p "${root_dir}/WEBrickLog"&lt;br /&gt;   /bin/chmod 0754 "${root_dir}" "${root_dir}/WEBrickLog"&lt;br /&gt;&lt;br /&gt;   /usr/bin/touch "${root_dir}/WEBrickLog/webrick.pid" "${root_dir}/WEBrickLog/webrick_ruby.pid"&lt;br /&gt;   /bin/chmod 0644 "${root_dir}/WEBrickLog/webrick.pid" "${root_dir}/WEBrickLog/webrick_ruby.pid"&lt;br /&gt;&lt;br /&gt;#   /usr/bin/touch "${root_dir}/index.html"&lt;br /&gt;#   /bin/chmod 0754 "${root_dir}/index.html"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/usr/local/bin/ruby &lt;&lt;-HEREDOC&lt;br /&gt;&lt;br /&gt;   require 'webrick'&lt;br /&gt;   require 'webrick/accesslog'&lt;br /&gt;   include WEBrick&lt;br /&gt;&lt;br /&gt;   require 'thread'&lt;br /&gt;   require 'pp'&lt;br /&gt;&lt;br /&gt;   root_dir = "${root_dir}"&lt;br /&gt;   http_dir = File.expand_path(root_dir)&lt;br /&gt;&lt;br /&gt;   File.open(http_dir + "/WEBrickLog/webrick_ruby.pid", "w") do |f|&lt;br /&gt;      f.puts(Process.pid)&lt;br /&gt;   end&lt;br /&gt;&lt;br /&gt;   # cf. http://microjet.ath.cx/webrickguide/html/Logging.html&lt;br /&gt;   webrick_log_file = File.expand_path(http_dir + "/WEBrickLog/webrick.log")&lt;br /&gt;   #webrick_log_file = '/dev/null'  # disable logging&lt;br /&gt;   webrick_logger = WEBrick::Log.new(webrick_log_file, WEBrick::Log::DEBUG)&lt;br /&gt;&lt;br /&gt;   access_log_stream = webrick_logger&lt;br /&gt;   access_log = [[ access_log_stream, WEBrick::AccessLog::COMBINED_LOG_FORMAT ]]&lt;br /&gt;&lt;br /&gt;   system_mime_table = WEBrick::HTTPUtils::load_mime_types('/private/etc/httpd/mime.types.default')&lt;br /&gt;   system_mime_table.store('rhtml', 'text/html')   # add a mime type for .rhtml files&lt;br /&gt;   system_mime_table.store('php', 'text/html')&lt;br /&gt;   system_mime_table.store('rb', 'text/plain')&lt;br /&gt;   system_mime_table.store('pid', 'text/plain')&lt;br /&gt;   #pp system_mime_table.sort_by { |k,v| k }&lt;br /&gt;&lt;br /&gt;   server = WEBrick::HTTPServer.new(&lt;br /&gt;     :BindAddress     =&gt;    "localhost",&lt;br /&gt;     :Port            =&gt;    9090,&lt;br /&gt;     :DocumentRoot    =&gt;    http_dir,&lt;br /&gt;     :FancyIndexing   =&gt;    true,&lt;br /&gt;     :MimeTypes       =&gt;    system_mime_table,&lt;br /&gt;     :Logger          =&gt;    webrick_logger,&lt;br /&gt;     :AccessLog       =&gt;    access_log&lt;br /&gt;   )&lt;br /&gt;&lt;br /&gt;   server.config.store(:DirectoryIndex, server.config[:DirectoryIndex] &lt;&lt; "default.htm")&lt;br /&gt;   #pp server.config&lt;br /&gt;&lt;br /&gt;   # cf. http://snippets.dzone.com/posts/show/5208&lt;br /&gt;   class TimeServlet &lt; HTTPServlet::AbstractServlet&lt;br /&gt;&lt;br /&gt;      def do_GET(req, res)&lt;br /&gt;         res['Content-Type'] = 'text/html'&lt;br /&gt;         res.status = 200&lt;br /&gt;         res.body = "&lt;html&gt;Time: #{Time.now.to_s}&lt;/html&gt;" + "\n"&lt;br /&gt;      end&lt;br /&gt;&lt;br /&gt;      # cf. http://www.hiveminds.co.uk/node/244, published under the&lt;br /&gt;      # GNU Free Documentation License, http://www.gnu.org/copyleft/fdl.html&lt;br /&gt;&lt;br /&gt;      @@instance = nil&lt;br /&gt;      @@instance_creation_mutex = Mutex.new&lt;br /&gt;&lt;br /&gt;      def self.get_instance(config, *options)&lt;br /&gt;         #pp @@instance&lt;br /&gt;         @@instance_creation_mutex.synchronize { &lt;br /&gt;            @@instance = @@instance || self.new(config, *options) }&lt;br /&gt;      end&lt;br /&gt;&lt;br /&gt;   end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   # cf. http://ttripp.blogspot.com/2007/01/fun-with-http.html&lt;br /&gt;   class PostDumper &lt; WEBrick::HTTPServlet::AbstractServlet&lt;br /&gt;  &lt;br /&gt;      # Reload file for each request, instantly&lt;br /&gt;      # updating the server with code changes &lt;br /&gt;      # without needing a restart.&lt;br /&gt;&lt;br /&gt;=begin&lt;br /&gt;      def PostDumper.get_instance( config, *options )&lt;br /&gt;         load __FILE__&lt;br /&gt;         PostDumper.new config, *options&lt;br /&gt;      end&lt;br /&gt;=end&lt;br /&gt;&lt;br /&gt;      # cf. http://www.hiveminds.co.uk/node/244, published under the&lt;br /&gt;      # GNU Free Documentation License, http://www.gnu.org/copyleft/fdl.html&lt;br /&gt;&lt;br /&gt;      @@instance = nil&lt;br /&gt;      @@instance_creation_mutex = Mutex.new&lt;br /&gt;&lt;br /&gt;      def self.get_instance(config, *options)&lt;br /&gt;         #pp @@instance&lt;br /&gt;         @@instance_creation_mutex.synchronize { &lt;br /&gt;            @@instance = @@instance || self.new(config, *options) }&lt;br /&gt;      end&lt;br /&gt;&lt;br /&gt;      def do_GET( request, response )&lt;br /&gt;         response.status = 200&lt;br /&gt;         response['Content-Type'] = "text/plain"&lt;br /&gt;         response.body = dump_request( request )&lt;br /&gt;      end&lt;br /&gt;  &lt;br /&gt;      def do_POST( request, response )&lt;br /&gt;         response.status = 200&lt;br /&gt;         response['Content-Type'] = "text/plain"&lt;br /&gt;         response.body = dump_request( request )&lt;br /&gt;         response.body &lt;&lt; request.body&lt;br /&gt;      end&lt;br /&gt;  &lt;br /&gt;      def dump_request( request )&lt;br /&gt;         request.request_line &lt;&lt; "\r\n" &lt;&lt;&lt;br /&gt;         request.raw_header.join( "" ) &lt;&lt; "\r\n"&lt;br /&gt;      end&lt;br /&gt;   end&lt;br /&gt;&lt;br /&gt;   server.mount("/dump", PostDumper)&lt;br /&gt;   server.mount("/time", TimeServlet, {:FancyIndexing=&gt;true})&lt;br /&gt;&lt;br /&gt;   # handle signals&lt;br /&gt;   %w(INT).each do |signal|&lt;br /&gt;      trap(signal) { server.shutdown }&lt;br /&gt;   end&lt;br /&gt;&lt;br /&gt;   server.start&lt;br /&gt;&lt;br /&gt;HEREDOC&lt;br /&gt;&lt;br /&gt;return 0&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;export -f webrick_local&lt;br /&gt;&lt;br /&gt;# start WEBrick alias&lt;br /&gt;alias webrick='swr'&lt;br /&gt;&lt;br /&gt;# start WEBrick&lt;br /&gt;unset -f swr&lt;br /&gt;function swr() {   &lt;br /&gt;  declare webrick_pid_file="${HOME}/Desktop/www/WEBrickLog/webrick.pid"&lt;br /&gt;  if [[ -e "${webrick_pid_file}" ]]; then echo "WEBrick already started!"; return 1; fi&lt;br /&gt;  /bin/bash -c "webrick_local" &amp;&lt;br /&gt;  declare WEBRICKPID=$!&lt;br /&gt;  mkdir -p "${HOME}/Desktop/www/WEBrickLog"&lt;br /&gt;  echo $WEBRICKPID &gt; "${HOME}/Desktop/www/WEBrickLog/webrick.pid"&lt;br /&gt;  return 0&lt;br /&gt;}&lt;br /&gt;export -f swr&lt;br /&gt;&lt;br /&gt;# quit WEBrick&lt;br /&gt;unset -f qwr&lt;br /&gt;function qwr() { &lt;br /&gt;   declare webrick_pid_file="${HOME}/Desktop/www/WEBrickLog/webrick.pid"&lt;br /&gt;   declare webrick_ruby_pid_file="${HOME}/Desktop/www/WEBrickLog/webrick_ruby.pid"&lt;br /&gt;   if [[ ! -e "${webrick_pid_file}" ]]; then echo "no such file: ${webrick_pid_file}"; return 1; fi&lt;br /&gt;   declare PIDW=$(cat "${webrick_pid_file}" 2&gt;/dev/null)&lt;br /&gt;   declare PIDR=$(cat "${webrick_ruby_pid_file}" 2&gt;/dev/null)&lt;br /&gt;   kill -INT $PIDW 2&gt;/dev/null || echo "no such PIDW: ${PIDW}"&lt;br /&gt;   kill -INT $PIDR 2&gt;/dev/null || echo "no such PIDR: ${PIDR}"&lt;br /&gt;   rm -f "${webrick_pid_file}" "${webrick_ruby_pid_file}"&lt;br /&gt;   return 0&lt;br /&gt;}&lt;br /&gt;export -f qwr&lt;br /&gt;&lt;br /&gt;# quit WEBrick; cf. Job Control Commands, http://tldp.org/LDP/abs/html/x8816.html&lt;br /&gt;###alias qwr='echo "quit WEBrick with ctrl-c ..."; fg %webrick 2&gt;/dev/null'&lt;br /&gt;&lt;br /&gt;alias openwww='/usr/bin/open http://localhost:9090'&lt;br /&gt;alias wrlog='/usr/bin/open http://localhost:9090/WEBrickLog/webrick.log'&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#----------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;source ~/.bash_login&lt;br /&gt;&lt;br /&gt;webrick&lt;br /&gt;&lt;br /&gt;openwww&lt;br /&gt;wrlog&lt;br /&gt;open http://localhost:9090 &lt;br /&gt;open http://localhost:9090/WEBrickLog&lt;br /&gt;open http://localhost:9090/WEBrickLog/webrick.log&lt;br /&gt;&lt;br /&gt;open http://localhost:9090/time&lt;br /&gt;open http://localhost:9090/dump&lt;br /&gt;&lt;br /&gt;wrlog&lt;br /&gt;qwr&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Further information:&lt;br /&gt;&lt;br /&gt;- &lt;a href="http://www.webrick.org"&gt;WEBrick&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://www.ruby-doc.org/stdlib/libdoc/webrick/rdoc/index.html"&gt;WEBrick RDoc&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://www.hiveminds.co.uk/node/245"&gt;What is WEBrick?&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://www.hiveminds.co.uk/node/244"&gt;Guide to using WEBrick for Rails development&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://www.igvita.com/2007/02/13/building-dynamic-webrick-servers-in-ruby/"&gt;Dynamic WEBrick Servers in Ruby&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://microjet.ath.cx/WebWiki/WEBrick.html"&gt;Gnome's Guide to WEBrick&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://codeidol.com/other/rubyckbk/Internet-Services/Running-Servlets-with-WEBrick/"&gt;Running Servlets with WEBrick&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://ruby.jamisbuck.org/rsphandler.rb"&gt;rsphandler&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://eigenclass.org/hiki/webrick-rewrite-rules"&gt;URL rewriting with WEBrick&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;</description>
      <pubDate>Tue, 17 Jun 2008 17:27:02 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5659</guid>
      <author>ntk ()</author>
    </item>
    <item>
      <title>Shell script to make lists of certain file types in a web site file system</title>
      <link>http://snippets.dzone.com/posts/show/5564</link>
      <description>mkdir file_lists&lt;br /&gt;find . -name '*.pdf' -o -name '*.PDF' &gt; ./file_lists/all_pdf_files.txt &lt;br /&gt;find . -name '*.pdf' -o -name '*.PDF' -mtime +365 &gt; ./file_lists/pdf_files_mtime_gt_1yr.txt&lt;br /&gt;&lt;br /&gt;find . -name '*.jpg' -o -name '*.JPG' -o -name '*.gif'  -o -name '*.GIF' -o -name '*.png' -o -name '*.PNG' &gt; ./file_lists/all_image_files.txt &lt;br /&gt;&lt;br /&gt;find . -name '*.log' -o -name '*.LOG' &gt; ./file_lists/all_log_files.txt&lt;br /&gt;&lt;br /&gt;find . -name '*.css' -o -name '*.CSS' -o -name '*.js'  -o -name '*.JS' &gt; ./file_lists/all_design_assets_files.txt &lt;br /&gt;&lt;br /&gt;find . -name '*.ram' -o -name '*.RAM' -o -name '*.aif'  -o -name '*.AIF' -o -name '*.mp3' -o -name '*.MP3' &gt; ./file_lists/all_audio_files.txt&lt;br /&gt;find . -name '*.ram' -o -name '*.RAM' -o -name '*.aif'  -o -name '*.AIF' -o -name '*.mp3' -o -name '*.MP3' -mtime +365 &gt; ./file_lists/audio_files_mtime_gt_1yr.txt &lt;br /&gt;&lt;br /&gt;find . -name '*.html' -o -name '*.HTML' -o -name '*.htm'  -o -name '*.HTM' &gt; ./file_lists/all_html_files.txt &lt;br /&gt;find . -name '*.html' -o -name '*.HTML' -o -name '*.htm'  -o -name '*.HTM' -mtime +365 &gt; ./file_lists/html_files_mtime_gt_1yr.txt</description>
      <pubDate>Sat, 31 May 2008 20:00:15 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5564</guid>
      <author>johnloy (John Loy)</author>
    </item>
    <item>
      <title>Use rsync to mirror directories between Virtual Hosts.</title>
      <link>http://snippets.dzone.com/posts/show/5561</link>
      <description>The following shell command will rsync the mysite.com directory 'feed' to mysite2.com&lt;br /&gt;&lt;code&gt;&lt;br /&gt;rsync -a /var/www/mysite.com/feed /var/www/mysite2.com&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 29 May 2008 23:16:58 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5561</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Inplace substitutions</title>
      <link>http://snippets.dzone.com/posts/show/5551</link>
      <description>Place all occurrences of "old value" with "new value" in all txt files.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;ruby -p -i -e '$_.gsub!("old value", "new value")' *.txt&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 28 May 2008 07:52:09 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5551</guid>
      <author>remvee (Remco van 't Veer)</author>
    </item>
  </channel>
</rss>
