<?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>linuxbuddies.com &#187; Scripts</title>
	<atom:link href="http://linuxbuddies.com/category/scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://linuxbuddies.com</link>
	<description>For linux documentations.</description>
	<lastBuildDate>Fri, 11 Sep 2009 10:11:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Email to Fax Gateway!</title>
		<link>http://linuxbuddies.com/2009/01/04/email-to-fax-gateway/</link>
		<comments>http://linuxbuddies.com/2009/01/04/email-to-fax-gateway/#comments</comments>
		<pubDate>Sun, 04 Jan 2009 08:49:12 +0000</pubDate>
		<dc:creator>Riyesh</dc:creator>
				<category><![CDATA[Hylafax]]></category>
		<category><![CDATA[Postfix]]></category>
		<category><![CDATA[Qmail]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Sendmail]]></category>
		<category><![CDATA[email to fax. email to fax gateway]]></category>
		<category><![CDATA[email2fax]]></category>
		<category><![CDATA[email2fax gateway. pdf fax]]></category>
		<category><![CDATA[jpeg fax]]></category>
		<category><![CDATA[msword fax]]></category>
		<category><![CDATA[postscript fax]]></category>
		<category><![CDATA[tiff fax]]></category>

		<guid isPermaLink="false">http://linuxbuddies.com/?p=257</guid>
		<description><![CDATA[This is an awasome feature of hylafax. User can send fax using email applications. Ex: riyesh@23656237.fax
We need to add some simple scipts to activate this feature.By defult hylafax will not decode the attachments.So you need to edit /etc/hylafax/hyla.conf.
specify mime type directory location in /etc/hylafax/hyla.conf
add the following line
MIMEConverters: /var/spool/hylafax/mimetype
Then create the ...]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-thumbnail wp-image-258" title="email2faxthump" src="http://linuxbuddies.com/wp-content/uploads/2009/01/email2faxthump-150x70.jpg" alt="email2faxthump" width="150" height="70" />This is an awasome feature of hylafax. User can send fax using email applications. Ex: riyesh@23656237.fax</p>
<p>We need to add some simple scipts to activate this feature.By defult hylafax will not decode the attachments.So you need to edit /etc/hylafax/hyla.conf.</p>
<p>specify mime type directory location in /etc/hylafax/hyla.conf</p>
<p>add the following line</p>
<blockquote><p>MIMEConverters: /var/spool/hylafax/mimetype</p></blockquote>
<p>Then create the converting scripts under /var/spool/hylafax/mimetype</p>
<blockquote><p>mkdir /var/spool/hylafax/mimetype</p></blockquote>
<p>you need to create followin directories under /var/spool/hylafax/mimetype</p>
<blockquote><p>mkdir application</p>
<p>mkdir image</p>
<p>mkdir text</p></blockquote>
<p>the tree look like this</p>
<blockquote><p>/var/spool/hylafax/mimetype/<br />
/var/spool/hylafax/mimetype/application/pdf<br />
/var/spool/hylafax/mimetype/application/ps<br />
/var/spool/hylafax/mimetype/image/tiff</p>
<p>/var/spool/hylafax/mimetype/text/html</p>
<p><span id="more-257"></span></p></blockquote>
<p><strong>For msword type of files </strong>create msword under /var/spool/hylafax/mimetype/application/</p>
<blockquote><p>cd /var/spool/hylafax/mimetype/application/</p>
<p>touch msword</p>
<p>chmod +x  msword</p>
<p>vi msword</p></blockquote>
<p>add the following lines in msword script</p>
<blockquote><p>#!/bin/bash<br />
antiword $1<br />
exit</p>
<p><!--more--></p></blockquote>
<p><strong>For PDF type of files</strong> create pdf under /var/spool/hylafax/mimetype/application/</p>
<blockquote><p>cd /var/spool/hylafax/mimetype/application/</p>
<p>touch pdf</p>
<p>chmod +x pdf</p>
<p>vi pdf</p></blockquote>
<p>add the following lines in pdf script</p>
<blockquote><p>#!/bin/sh<br />
#/application/pdf<br />
# convert PDF attachment to Postscript for HylaFAX to send<br />
pdf2ps $1 -<br />
# if you want to send multipage pdf attachments it is better to use &#8220;pdftops&#8221;<br />
# use the line below instead of &#8220;pdf2ps $1 -&#8221;<br />
# /usr/bin/pdftops $1 -</p>
<p><!--more--><strong><br />
</strong></p></blockquote>
<p><strong>For postscript type of files</strong> create postscript under /var/spool/hylafax/mimetype/application/</p>
<blockquote><p>cd /var/spool/hylafax/mimetype/application/</p>
<p>touch postscript</p>
<p>chmod +x postscript</p>
<p>vi postscript</p></blockquote>
<p>add the following lines in postscript script</p>
<blockquote><p>#!/bin/sh<br />
#/application/pdf<br />
# convert PDF attachment to Postscript for HylaFAX to send<br />
pdf2ps $1 -<br />
# if you want to send multipage pdf attachments it is better to use &#8220;pdftops&#8221;<br />
# use the line below instead of &#8220;pdf2ps $1 -&#8221;<br />
# /usr/bin/pdftops $1 -<br />
mail:/var/spool/hylafax/mimetype/application #<br />
mail:/var/spool/hylafax/mimetype/application # cat postscript<br />
#!/bin/sh<br />
#/application/ps<br />
# convert PS attachment to Postscript for HylaFAX to send<br />
echo $1</p></blockquote>
<p><!--more--><strong>For PS attachment files </strong>create ps under /var/spool/hylafax/mimetype/application</p>
<blockquote><p>cd /var/spool/hylafax/mimetype/application/</p>
<p>touch postscript</p>
<p>chmod +x postscript</p>
<p>vi postscript</p></blockquote>
<p>add the following lines in ps script</p>
<blockquote><p>#!/bin/sh<br />
#/application/ps<br />
# convert PS attachment to Postscript for HylaFAX to send<br />
echo $1</p></blockquote>
<p><!--more--><strong>For rtf attachement files</strong> create rtf under /var/spool/hylafax/mimetype/application</p>
<blockquote><p>cd /var/spool/hylafax/mimetype/application/</p>
<p>touch rtf</p>
<p>chmod +x rtf</p>
<p>vi rtf</p></blockquote>
<p>add the following lines in rtf</p>
<blockquote><p>#!/bin/sh<br />
#/application/rtf<br />
# convert RTF attachment to Postscript for HylaFAX to send<br />
/usr/bin/unrtf &#8211;html $1 | /usr/bin/html2ps</p></blockquote>
<p><!--more--><strong>For jpeg attachment files </strong>create jpeg under  /var/spool/hylafax/mimetype/image</p>
<blockquote><p>cd /var/spool/hylafax/mimetype/image</p>
<p>touch image</p>
<p>chmod +x image</p>
<p>vi image</p></blockquote>
<p>add the following lines in jpeg</p>
<blockquote><p>#! /bin/sh<br />
/usr/bin/jpeg2ps  $1<br />
exit</p>
<p><!--more--></p></blockquote>
<p><strong>For tiff attachment files </strong>create tiff under /var/spool/hylafax/mimetype/image</p>
<blockquote><p>cd /var/spool/hylafax/mimetype/image</p>
<p>touch tiff</p>
<p>chmod +x tiff<br />
vi tiff</p></blockquote>
<p>Then add the following lines</p>
<blockquote><p>#! /bin/sh<br />
/usr/bin/jpeg2ps  $1<br />
exit<br />
mail:/var/spool/hylafax/mimetype/image # cat tiff<br />
#!/bin/sh<br />
#/image/tif<br />
# convert TIF attachment to Postscript for HylaFAX to send<br />
/usr/bin/tiff2ps $1<br />
# if you want to send multipage tiff images, than you have to add the option &#8220;-a&#8221;<br />
# for example:<br />
#/usr/bin/tiff2ps -a $1</p></blockquote>
<p><!--more--><strong>For HTML type  files</strong> create html under /var/spool/hylafax/mimetype/text</p>
<blockquote><p>cd /var/spool/hylafax/mimetype/text</p>
<p>touch html</p>
<p>chmod +x html<br />
vi html</p></blockquote>
<p>then add the following lines.</p>
<blockquote><p>#! /bin/sh<br />
/usr/bin/html2ps   $1<br />
exit</p>
<p><!--more--></p></blockquote>
<p><strong>Integrating with MTA&#8217;s </strong></p>
<blockquote><p><strong><br />
</strong></p></blockquote>
<blockquote><p>cd /usr/src/hylafax-(source package)</p>
<p>cd faxmail</p></blockquote>
<p>there you can see the files</p>
<blockquote><p>mailfax.sh-sendmail</p>
<p>mailfax.sh-postfix</p>
<p>mailfax.sh-qmail</p>
<p>mailfax.sh-smail</p></blockquote>
<p>do as per the files says.</p>
]]></content:encoded>
			<wfw:commentRss>http://linuxbuddies.com/2009/01/04/email-to-fax-gateway/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Collecting User IP!</title>
		<link>http://linuxbuddies.com/2009/01/03/collecting-user-ip/</link>
		<comments>http://linuxbuddies.com/2009/01/03/collecting-user-ip/#comments</comments>
		<pubDate>Sat, 03 Jan 2009 07:14:44 +0000</pubDate>
		<dc:creator>Riyesh</dc:creator>
				<category><![CDATA[Network]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[bash scripting]]></category>
		<category><![CDATA[cgi scripting]]></category>
		<category><![CDATA[ip]]></category>
		<category><![CDATA[msyql]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[users IP]]></category>

		<guid isPermaLink="false">http://linuxbuddies.com/?p=272</guid>
		<description><![CDATA[A sample BASH CGI script for collecting IPs of your colleagues in your network.
Prerequisites 
1) apache/cgi configuration
2) a Mysql installation
Then create script &#8220;getip.sh&#8221; under &#8220;/var/www/cgi-bin/&#8221;  ( set location of cgi-bin directory  as per the apache configuration) 
#!/bin/bash #Getting IP address CGI-BASH-script#Jadu Saikia http://unstableme.blogspot.com/ #MySQL settings
# MHOME=  ( location of mysql ...]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-273" title="ip" src="http://linuxbuddies.com/wp-content/uploads/2009/01/ip.jpg" alt="ip" width="138" height="112" /><span style="color: #000000;">A sample BASH CGI script for collecting IPs of your colleagues in your network.</span></p>
<p><strong><span style="color: #000000;">Prerequisites </span></strong><br />
<span style="color: #000000;">1) apache/cgi configuration</span><br />
<span style="color: #000000;">2) a Mysql installation</span></p>
<p><span style="color: #000000;">Then create script &#8220;getip.sh&#8221; under &#8220;/var/www/cgi-bin/&#8221;  ( set location of cgi-bin directory  as per the apache configuration) </span></p>
<p style="padding-left: 30px;"><span style="font-size: x-small;"><span style="font-family: courier new,monospace;">#!/bin/bash</span><br style="font-family: courier new,monospace;" /> <span style="font-family: courier new,monospace;">#Getting IP address CGI-BASH-script</span><br style="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;">#Jadu Saikia <a href="http://unstableme.blogspot.com/" target="_blank">http://unstableme.blogspot.com/</a></span><br style="font-family: courier new,monospace;" /> <br style="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;">#MySQL settings</span></span></p>
<p style="padding-left: 30px;"><span style="font-size: x-small;"># MHOME=  ( location of mysql binary)<br style="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;">MHOME=/usr/local/mysql/bin</span><br style="font-family: courier new,monospace;" /> <span style="font-family: courier new,monospace;">HOST=127.0.0.1</span><br style="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;">USER=root</span><br style="font-family: courier new,monospace;" /> <span style="font-family: courier new,monospace;">PASS=&#8221;"</span><br style="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;">DB=mydb</span><br style="font-family: courier new,monospace;" /> <br style="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;">OWNER=$(echo &#8220;$QUERY_STRING&#8221; |awk -F &#8220;=&#8221; &#8216;{print $NF}&#8217;)</span><br style="font-family: courier new,monospace;" /> <span style="font-family: courier new,monospace;">IP=$REMOTE_ADDR</span><br style="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;">#QUERY_STRING = Query information that follows the ? in the URL that referenced this script.</span><br style="font-family: courier new,monospace;" /> <span style="font-family: courier new,monospace;">#REMOTE_ADDR = IP address of the remote host making the request</span><br style="font-family: courier new,monospace;" /><br style="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;">#HTML Output</span><br style="font-family: courier new,monospace;" /> <span style="font-family: courier new,monospace;">echo &#8220;Content-type: text/html&#8221;</span><br style="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;">echo &#8220;&#8221;</span><br style="font-family: courier new,monospace;" /> <span style="font-family: courier new,monospace;">echo &#8220;&lt;html&gt;&lt;head&gt;&lt;title&gt;YOUR IP&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;I am collecting the IPs&lt;/h1&gt;&lt;pre&gt;&#8221;;</span><br style="font-family: courier new,monospace;" /> <span style="font-family: courier new,monospace;">echo &#8220;IP: &lt;em&gt;$IP&lt;/em&gt;&lt;br /&gt;&#8221;</span><br style="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;">echo &#8220;You Are IP is : &lt;em&gt;$OWNER&lt;/em&gt;&lt;br /&gt;&#8221;</span><br style="font-family: courier new,monospace;" /> <br style="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;">$MHOME/mysql -u$USER -h$HOST &#8211;password=$PASS -e &#8220;INSERT INTO mydb.ips(rdate,ip,owner) VALUES(NOW(),&#8217;$IP&#8217;,'$OWNER&#8217;)&#8221; $DB</span><br style="font-family: courier new,monospace;" /> <br style="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;">echo &#8220;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;&#8221;;</span></span></p>
<p>Then</p>
<p><span style="color: #000000;">Create MySql Database for storing the data. </span></p>
<p><span style="color: #000000;">logon to mysql </span></p>
<p style="padding-left: 30px;"><span style="color: #000000;">mysql -u root -p password </span></p>
<p><span style="color: #000000;">create database and table</span></p>
<p><span style="color: #000000;"> create database mydb<br />
</span></p>
<p style="padding-left: 30px;"><span style="color: #000000;">use mydb<br />
</span></p>
<p style="padding-left: 30px;"><span style="color: #000000;">create table </span><span style="font-family: courier new,monospace;">mydb.ips (</span> <span style="font-family: courier new,monospace;">rdate DATE,</span> <span style="font-family: courier new,monospace;">ip VARCHAR(20) NOT NULL PRIMARY KEY,</span> <span style="font-family: courier new,monospace;">owner VARCHAR(25)</span><span style="font-family: courier new,monospace;">);</span></p>
<p style="padding-left: 30px;"><span style="font-family: courier new,monospace;">exit</span></p>
<p>Suppose the IP of the box where you are running the cgi is &#8220;172.22.22.188&#8243; (your local ip).</p>
<p>Now construct the urls for your colleagues this way:</p>
<p><a href="http://172.22.22.188/cgi-bin/retrip.sh?owner=alexm" target="_blank">http://172.22.22.188/cgi-bin/getip.sh?owner=alexm</a><br />
<a href="http://172.22.22.188/cgi-bin/retrip.sh?owner=nsarma" target="_blank">http://172.22.22.188/cgi-bin/getip.sh?owner=nsarma</a><br />
&#8230;<br />
&#8230;</p>
<p>And send them the individual urls in mail with a request to click the url (just to help you collecting the ips in the mysql table)</p>
<p>Once they click, your database table will be automatically populated with datas like this:</p>
<p>mysql&gt; select * from mydb.ips;<br />
+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+</p>
<div id=":2xf" class="ArwC7c ckChnd">&#8212;&#8212;&#8212;+<br />
| rdate | ip | owner |<br />
+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+<br />
| 2007-01-02 | 172.22.22.111 | alexm |<br />
| 2007-01-03 | 172.22.22.92 | nsarma |<br />
+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+<br />
2 rows in set (0.00 sec)</div>
<div class="ArwC7c ckChnd">Finished.</div>
<p><span style="font-family: courier new,monospace;"><br />
</span></p>
<p><span style="font-family: courier new,monospace;"><br />
</span></p>
<p><span style="color: #000000;"><br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://linuxbuddies.com/2009/01/03/collecting-user-ip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Server monitoring script!</title>
		<link>http://linuxbuddies.com/2008/12/26/server-monitoring-script/</link>
		<comments>http://linuxbuddies.com/2008/12/26/server-monitoring-script/#comments</comments>
		<pubDate>Fri, 26 Dec 2008 08:31:31 +0000</pubDate>
		<dc:creator>Riyesh</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[server tweak]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[shell script]]></category>

		<guid isPermaLink="false">http://linuxbuddies.com/?p=235</guid>
		<description><![CDATA[Please do  this script on your own risk, first test this script on test machine. then do it on live server 
 
 
#!/bin/bash
EMAIL=”riyesh@linuxbuddies.com”
SUBJECT=”Alert $(hostname) load average is $L05?
TEMPFILE=”/tmp/$(hostname)”
echo “Load average Crossed allowed limit.” &#62;&#62; $TEMPFILE
echo “Hostname: $(hostname)” &#62;&#62; $TEMPFILE
echo “Local Date &#38; Time : $(date)” &#62;&#62; $TEMPFILE
echo “&#124; Uptime status: &#124;” &#62;&#62; ...]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-234" title="bash-shell1" src="http://linuxbuddies.com/wp-content/uploads/2008/12/bash-shell1.png" alt="bash-shell1" width="128" height="128" />Please do  this script on your own risk, first test this script on test machine. then do it on live server </p>
<p> </p>
<p> </p>
<p class="MsoNormal">#!/bin/bash<br />
EMAIL=”riyesh@linuxbuddies.com”<br />
SUBJECT=”Alert $(hostname) load average is $L05<span>?</span><br />
TEMPFILE=”/tmp/$(hostname)”<br />
echo “Load average Crossed allowed limit.” &gt;&gt; $TEMPFILE<br />
echo “Hostname: $(hostname)” &gt;&gt; $TEMPFILE<br />
echo “Local Date &amp; Time : $(date)” &gt;&gt; $TEMPFILE<br />
echo “| Uptime status: |” &gt;&gt; $TEMPFILE<br />
echo “——————————————-” &gt;&gt; $TEMPFILE<br />
/usr/bin/uptime &gt;&gt; $TEMPFILE<br />
echo “——————————————-” &gt;&gt; $TEMPFILE<br />
echo “| Top 20 CPU consuming processes: |” &gt;&gt; $TEMPFILE<br />
ps aux | head -1 &gt;&gt; $TEMPFILE<br />
ps aux –no-headers | sort -rn +2 | head -20 &gt;&gt; $TEMPFILE<br />
echo “| Top 10 memory-consuming processes: |” &gt;&gt; $TEMPFILE<br />
ps aux –no-headers| sort -rn +3 | head &gt;&gt; $TEMPFILE<br />
echo “——————————————-” &gt;&gt; $TEMPFILE<br />
echo “| Memory and Swap status: |” &gt;&gt; $TEMPFILE<br />
/usr/bin/free -m &gt;&gt; $TEMPFILE<br />
echo “——————————————-” &gt;&gt; $TEMPFILE<br />
echo “| Active network connection: |” &gt;&gt; $TEMPFILE<br />
echo “——————————————-” &gt;&gt; $TEMPFILE<br />
/bin/netstat -tnup | grep ESTA &gt;&gt; $TEMPFILE<br />
echo “——————————————-” &gt;&gt; $TEMPFILE<br />
echo “| Disk Space information: |” &gt;&gt; $TEMPFILE<br />
echo “——————————————-” &gt;&gt; $TEMPFILE<br />
/bin/df -h &gt;&gt; $TEMPFILE<br />
echo “—————–THE END——————-” &gt;&gt; $TEMPFILE<br />
L05=”$(uptime|awk ‘{print $(NF-2)}’|cut -d. -f1)”<br />
if test $L05 -gt 5<br />
then<br />
mail -s “$SUBJECT” “$EMAIL” &lt; $TEMPFILE<br />
fi<br />
rm -f $TEMPFILE</p>
]]></content:encoded>
			<wfw:commentRss>http://linuxbuddies.com/2008/12/26/server-monitoring-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
