<?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>mochahochabeachside.com &#187; Scripts</title>
	<atom:link href="http://mochahochabeachside.com/topics/scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://mochahochabeachside.com</link>
	<description></description>
	<lastBuildDate>Tue, 10 May 2011 04:31:12 +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>Auto-install of WordPress Theme from CLI</title>
		<link>http://mochahochabeachside.com/2010/03/auto-install-of-wordpress-theme-from-cli/</link>
		<comments>http://mochahochabeachside.com/2010/03/auto-install-of-wordpress-theme-from-cli/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 14:27:59 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[install script]]></category>
		<category><![CDATA[themes]]></category>

		<guid isPermaLink="false">http://mochahochabeachside.com/?p=119</guid>
		<description><![CDATA[If you're like me, and you still like to install your WordPress themes from the command line (or you were 3/4 asleep and forgot WordPress now has a nice, easy-to-use auto-installer built into the admin interface), you know it can be a pain.  You have to download the file, unzip it, make sure it's right, [...]]]></description>
			<content:encoded><![CDATA[<p>If you're like me, and you still like to install your WordPress themes from the command line (or you were 3/4 asleep and forgot WordPress now has a nice, easy-to-use auto-installer built into the admin interface), you know it can be a pain.  You have to download the file, unzip it, make sure it's right, delete the archive, chwon the files, etc...  It can be a pain.</p>
<p>So, I created a nice little script to take care of all of that.  wpthemeget will take a download URL from the WordPress Themes directory (in the format of http://(<a href="http://(www.)wordpress.org/extend/themes/download/themename.ver.zip">www.)wordpress.org/extend/themes/download/themename.ver.zip</a> (or .tar.gz, or .tgz)), and will download, unarchive, chown, and remove the downloaded file, with no muss or fuss...  The output?:</p>
<p style="padding-left: 30px;"><a href="mailto:root@fyre">root@fyre</a> [.../wp-content/themes]# wpthemeget <a href="http://wordpress.org/extend/themes/">http://wordpress.org/extend/themes/</a>                                        download/motion.1.0.4.zip<br />
Downloading theme motion.1.0.4.zip...<br />
Theme is a zip archive...<br />
Unzipping... [COMPLETE]<br />
...Removing downloaded archive file... removed `motion.1.0.4.zip'<br />
...Chowning files... [COMPLETE]<br />
...Installation Complete!</p>
<p>No muss, no fuss. The <em>only</em> caveat is that you have to be in your themes directory when you run it.  Future versions probably won't have this requirement, but hey, I hacked this out when I was barely awake, on heavy medication, and repeatedly falling asleep at the keyboard.  At one point, I had to delete something like 40 lines of "zzzzzzzzzzz......" because I fell asleep with my finger on the key.  Fortunately, vi treated it as all one paragraph so '&lt;esc&gt; dd' did the job.  The code for this little script is after the break.  Grab it, chmod it to exec, and drop it in /usr/local/bin, and it'll be good to go anywhere on your system, for all your blogs.  Happy blogging!</p>
<p><span id="more-119"></span></p>
<p><code># wpthemeget - WordPress Theme Installer<br />
# by: Eric Scalf -- @ericscalf.com<br />
# Licensed under SPL (Scalf Public License) v.10<br />
# You are licensed to take, use, and modify this script as you wish, provided<br />
# you give attribution to the original author, and do not use the script for commercial use<br />
# or monetary gain, without first obtaining permission from the original author.<br />
# failure to do so constitutes a breach of license, and you agree that each breach of license<br />
# incurs a fine of $15,000 USD payable to the original author.<br />
#Non-commercial use of this script is encouraged, as is non-commercial distribution.<br />
#<br />
#!/bin/bash<br />
if [ -z "$1" ]<br />
then<br />
        echo "You must enter an URL for theme download..."<br />
        echo "The scrit is called thus:"<br />
        echo $0 "&lt;url&gt;"<br />
        echo<br />
        exit 9<br />
fi</p>
<p>echo -n "Downloading theme "<br />
echo $(echo "<a href="http://wordpress.org/extend/themes/download/motion.1.0.4.zip">http://wordpress.org/extend/themes/download/motion.1.0.4.zip</a>" | cut -d/ -f7)"..."<br />
wget $1 &gt; /dev/null 2&gt;&amp;1<br />
if [ -z $(echo "${1}" | egrep tar[.]gz\|tgz) ]<br />
then<br />
        echo "Theme is a zip archive..."<br />
        ZFILE=$(echo "<a href="http://wordpress.org/extend/themes/download/motion.1.0.4.zip">http://wordpress.org/extend/themes/download/motion.1.0.4.zip</a>" | cut -d/ -f7)<br />
        echo -n "Unzipping... "<br />
        unzip ${ZFILE} &gt; /dev/null<br />
        echo "[COMPLETE]"<br />
        echo -n "...Removing downloaded archive file..."<br />
        rm -fv ${ZFILE}<br />
        echo -n "...Chowning files... "<br />
        TUSER=$(echo ${PWD} | cut -d/ -f3)<br />
        chown -R ${TUSER}.${TUSER} * &gt; /dev/null<br />
        echo "[COMPLETE]"<br />
        echo "...Installation Complete!"<br />
        echo ""<br />
        exit 0<br />
else<br />
        echo "Theme is a .tar.gz or .tgz archive..."<br />
        ZFILE=$(echo "<a href="http://wordpress.org/extend/themes/download/motion.1.0.4.zip">http://wordpress.org/extend/themes/download/motion.1.0.4.zip</a>" | cut -d/ -f7)<br />
        echo -n "Unarchiving... "<br />
        tar -xzf ${ZFILE} &gt; /dev/null<br />
        echo "[COMPLETE]"<br />
        echo -n "...Removing downloaded archive file... "<br />
        rm -fv ${ZFILE}<br />
        echo -n "...Chowning files... "<br />
        TUSER=$(echo ${PWD} | cut -d/ -f3)<br />
        chown -R ${TUSER}/${TUSER} * &gt; /dev/null<br />
        echo "[COMPLETE]"<br />
        echo "...Installation Complete!"<br />
        echo ""<br />
        exit 0<br />
fi</code></p>
]]></content:encoded>
			<wfw:commentRss>http://mochahochabeachside.com/2010/03/auto-install-of-wordpress-theme-from-cli/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Default Mail Clean Script</title>
		<link>http://mochahochabeachside.com/2009/03/default-mail-clean-script/</link>
		<comments>http://mochahochabeachside.com/2009/03/default-mail-clean-script/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 08:22:17 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[CPanel]]></category>
		<category><![CDATA[FAQs  Help  and Tutorials]]></category>

		<guid isPermaLink="false">http://mochahochabeachside.com/?p=29</guid>
		<description><![CDATA[Here's a quick little script to clean the default mail accounts of mail on cPanel servers.  Note that this only helps if you have already disabled the catchalls. #!/bin/bash ############################################### # CLEAN MAIL # # v0.1 # # # # Cleans the mail from default accounts based # # on cPanel usernames. Create a file [...]]]></description>
			<content:encoded><![CDATA[<p>Here's a quick little script to clean the default mail accounts of mail on cPanel servers.  Note that this only helps if you have already disabled the catchalls.</p>
<p><code>#!/bin/bash<br />
###############################################<br />
#                CLEAN MAIL                   #<br />
#                   v0.1                      #<br />
#                                             #<br />
# Cleans the mail from default accounts based #<br />
# on cPanel usernames. Create a file in /root #<br />
# called 'doit'.  Add one cPanel username per #<br />
# line.  That should do nicely. Oh, this will #<br />
# take a while, so run the sucker in screen,  #<br />
# mkay, Batman?                               #<br />
###############################################</code></p>
<p><code># Some dedis have LS_OPTIONS include -a...<br />
# that would be bad for this script.<br />
# so, we reset it.<br />
LS_OPTIONS='-A'</code></p>
<p><code># start the loop...<br />
for i in `cat /root/doit`<br />
do<br />
        # Delete from the new folder.<br />
        cd /home/$i/mail/new<br />
        # can't rm if there's too many, and by using<br />
        # an ls and awk, we avoid another loop.<br />
        ls -l | awk '{print "rm -fv "$9}'|bash<br />
        # Delete from the cur folder.<br />
        cd /home/$i/mail/cur<br />
        # Comment repetition carefully avoided, here <img src='http://mochahochabeachside.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
        ls -l | awk '{print "rm -fv "$9}'|bash<br />
done<br />
# NINJAMOJO!</code></p>
<p>It's simple. Get a list of cPanel usernames, one per line, create a file in /root called 'doit', and slap the usernames in there.  Then, 'bash cleanmail'.</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif" alt="" /><span class="zem-script more-related"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
]]></content:encoded>
			<wfw:commentRss>http://mochahochabeachside.com/2009/03/default-mail-clean-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing Random Randomness&#8230;</title>
		<link>http://mochahochabeachside.com/2009/02/testing-random-randomness/</link>
		<comments>http://mochahochabeachside.com/2009/02/testing-random-randomness/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 09:30:11 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[shell scripts]]></category>

		<guid isPermaLink="false">http://mochahochabeachside.com/?p=12</guid>
		<description><![CDATA[A post at Manik 2.0 got me thinking on whether or not the $RANDOM variable in bash was really all that random.  So, I created a little test script.  It's quite simple.  It accepts a command line argument for number of loops. Then, each loop, it assigns a random number to $RANDTEST, and then compares [...]]]></description>
			<content:encoded><![CDATA[<p>A <a href="http://manikandakumar.blogspot.com/2007/07/writing-shell-scripts.html">post at Manik 2.0</a> got me thinking on whether or not the $RANDOM variable in bash was really all that random.  So, I created a little test script.  It's quite simple.  It accepts a command line argument for number of loops. Then, each loop, it assigns a random number to $RANDTEST, and then compares $RANDTEST to $RANDOM. Since $RANDOM changes every time, it should never, ever match.</p>
<p><span id="more-12"></span>There are two primary schools of thought about this... One statest that $RANDOM is random at all times.  Another than $RANDOM is not random enough, unless seeded.  Therefore, I've created this script to test on both schools of thought.  To test with $RANDOM seeded, uncommend the second line. This seeds $RANDOM off of the pid of the script. Otherwise, $RANDOM is untested.</p>
<p><code>#!/bin/bash<br />
#RANDOM=$$<br />
RANDTEST=0<br />
DOWHILE=1<br />
LIMIT=$1<br />
while [ "${DOWHILE}" -lt "${LIMIT}" ]<br />
do<br />
RANDTEST=${RANDOM}<br />
if [ "${RANDTEST}" -eq "${RANDOM}" ]<br />
then<br />
echo "MATCH! (...on ${DOWHILE})"<br />
fi<br />
let "DOWHILE = ${DOWHILE} + 1"<br />
done</code></p>
<p>I haven't had the time to put it through serious paces, but tonight I'll open a terminal on my desktop (ubuntu), and let it run for a few million loops.  We'll see what comes up.</p>
]]></content:encoded>
			<wfw:commentRss>http://mochahochabeachside.com/2009/02/testing-random-randomness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

