<?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>SHARE Lifetime Experience</title>
	<atom:link href="http://blog.rudylee.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.rudylee.com</link>
	<description>Someone that want to share something</description>
	<lastBuildDate>Sat, 04 Sep 2010 00:42:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Add bridge and assign unique IP for each container in OpenVZ</title>
		<link>http://blog.rudylee.com/2010/08/30/add-bridge-assign-unique-ip-for-each-container-in-openvz/</link>
		<comments>http://blog.rudylee.com/2010/08/30/add-bridge-assign-unique-ip-for-each-container-in-openvz/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 03:33:27 +0000</pubDate>
		<dc:creator>Rudy</dc:creator>
				<category><![CDATA[Unix dan Linux]]></category>
		<category><![CDATA[bridge]]></category>
		<category><![CDATA[openvz]]></category>
		<category><![CDATA[venet]]></category>
		<category><![CDATA[veth]]></category>

		<guid isPermaLink="false">http://blog.rudylee.com/?p=538</guid>
		<description><![CDATA[I am writing this tutorial to refresh my mind ( I am not configuring the machine right now ), so forgive if me the explanations are not clear and structured.
After you successfully installed the OpenVZ you need to configure the IP for the containers. If you are using the built in &#8220;Venet&#8221; you will end [...]<p><a href="http://blog.rudylee.com/2010/08/30/add-bridge-assign-unique-ip-for-each-container-in-openvz/">Add bridge and assign unique IP for each container in OpenVZ</a> is a post from: <a href="http://blog.rudylee.com">SHARE Lifetime Experience</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I am writing this tutorial to refresh my mind ( I am not configuring the machine right now ), so forgive if me the explanations are not clear and structured.</p>
<p>After you successfully installed the OpenVZ you need to configure the IP for the containers. If you are using the built in &#8220;Venet&#8221; you will end up making the host as the gateway. In the other words if you traceroute to your container IP, it will through your host then to your container. Here are the sample of the scenario :</p>
<ol>
<li>Host IP : 202.58.181.2</li>
<li>Container 1 : 202.58.181.50</li>
<li>Container 2 : 202.58.181.51</li>
</ol>
<p>Basically if you use the venet, if you traceroute to the Container 1 the result should be : Your ISP -> 202.58.181.2 -> 202.58.181.50 so the IP of the Host is showed up. Same if try to traceroute to the second container. My solution to overcome this problem are :</p>
<ol>
<li>Make a bridge using brctl command</li>
<li>Use the Veth instead of Venet</li>
<li>Put all the Veth into the bridge</li>
<li>Assign the Host IP to the bridge</li>
</ol>
<p>If you not ASSIGN the host IP to the bridge, you can&#8217;t access the host machine. The guidelines that I followed is from link <a href="http://wiki.openvz.org/Using_veth_and_brctl_for_protecting_HN_and_saving_IP_addresses">http://wiki.openvz.org/Using_veth_and_brctl_for_protecting_HN_and_saving_IP_addresses</a></p>
<p>Here is my /etc/rc.local configuration looks like :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># This script will be executed *after* all the other init scripts.</span>
<span style="color: #666666; font-style: italic;"># You can put your own initialization stuff in here if you don't</span>
<span style="color: #666666; font-style: italic;"># want to do the full Sys V style init stuff.</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lock<span style="color: #000000; font-weight: bold;">/</span>subsys<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span>
brctl addbr vzbr0
brctl addif vzbr0 eth0
brctl addif vzbr0 veth1.0
brctl addif vzbr0 veth2.0
brctl addif vzbr0 veth3.0
brctl addif vzbr0 veth4.0
<span style="color: #c20cb9; font-weight: bold;">ifconfig</span> vzbr0 <span style="color: #000000;">0</span>
ip addr add 202.58.181.2<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">25</span> dev vzbr0
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>webvz<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ruby script<span style="color: #000000; font-weight: bold;">/</span>server <span style="color: #000000; font-weight: bold;">&amp;&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000; font-weight: bold;">&amp;</span></pre></td></tr></table></div>

<p>I&#8217;ll update this post if I need to configure another VPS Server.</p>
<p><a href="http://blog.rudylee.com/2010/08/30/add-bridge-assign-unique-ip-for-each-container-in-openvz/">Add bridge and assign unique IP for each container in OpenVZ</a> is a post from: <a href="http://blog.rudylee.com">SHARE Lifetime Experience</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rudylee.com/2010/08/30/add-bridge-assign-unique-ip-for-each-container-in-openvz/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sydney PHP Group</title>
		<link>http://blog.rudylee.com/2010/08/12/sydney-php-group/</link>
		<comments>http://blog.rudylee.com/2010/08/12/sydney-php-group/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 03:01:03 +0000</pubDate>
		<dc:creator>Rudy</dc:creator>
				<category><![CDATA[My Stories]]></category>

		<guid isPermaLink="false">http://blog.rudylee.com/?p=529</guid>
		<description><![CDATA[Sydney PHP Group or sydphp is a PHP community in Sydney, Australia. I found the website when I was reading an article in Graham Weldon&#8217;s blog. Graham is one of the CakePHP core team and also the organisers of Sydney PHP Group. 
From what I read, it&#8217;s said that they run regular meetings in the [...]<p><a href="http://blog.rudylee.com/2010/08/12/sydney-php-group/">Sydney PHP Group</a> is a post from: <a href="http://blog.rudylee.com">SHARE Lifetime Experience</a></p>
]]></description>
			<content:encoded><![CDATA[<p><a href="http://sydphp.org">Sydney PHP Group or sydphp</a> is a PHP community in Sydney, Australia. I found the website when I was reading an article in <a href="http://www.grahamweldon.com">Graham Weldon&#8217;s blog</a>. Graham is one of the CakePHP core team and also the organisers of Sydney PHP Group. </p>
<p>From what I read, it&#8217;s said that they run regular meetings in the city. But when I clicked it, it didn&#8217;t show any histories or upcoming events ( maybe they not runs it regularly as they said ). That&#8217;s fine at least I found already one of the PHP community in Australia, yay <img src='http://blog.rudylee.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  plus it has the job vacancies post in it ( so I think I won&#8217;t have any difficulty to find any freelancer job if I were in Sydney ). <img src='http://blog.rudylee.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><a href="http://blog.rudylee.com/2010/08/12/sydney-php-group/">Sydney PHP Group</a> is a post from: <a href="http://blog.rudylee.com">SHARE Lifetime Experience</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rudylee.com/2010/08/12/sydney-php-group/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>First post in August 2010</title>
		<link>http://blog.rudylee.com/2010/08/11/first-post-in-august-2010/</link>
		<comments>http://blog.rudylee.com/2010/08/11/first-post-in-august-2010/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 10:36:15 +0000</pubDate>
		<dc:creator>Rudy</dc:creator>
				<category><![CDATA[My Stories]]></category>

		<guid isPermaLink="false">http://blog.rudylee.com/?p=525</guid>
		<description><![CDATA[Hmm it&#8217;s August already and that&#8217;s mean my time in Binus is just two months left. Yeah, my contract will be ended on 31st October ( I hope so   ). There are so much experiences that I got while working in Binus, not mentioning the technical experiences but more about the life experiences. [...]<p><a href="http://blog.rudylee.com/2010/08/11/first-post-in-august-2010/">First post in August 2010</a> is a post from: <a href="http://blog.rudylee.com">SHARE Lifetime Experience</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Hmm it&#8217;s August already and that&#8217;s mean my time in Binus is just two months left. Yeah, my contract will be ended on 31st October ( I hope so <img src='http://blog.rudylee.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  ). There are so much experiences that I got while working in Binus, not mentioning the technical experiences but more about the life experiences. </p>
<p>The last 3 weeks I was busy taking my IELTS preparation course, it&#8217;s teach you to get accustomed to the IELTS test. The course has 4 parts : the speaking ( in which I needed the most ), the writing ( I have difficulties to write in Indonesian but now I have to write in English, damn ), the reading and the listening. The parts that I most feared are the speaking and the writing ( that&#8217;s why I am practicing right now by writing my blog post using English <img src='http://blog.rudylee.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  ). The IELTS course will be over on 23rd August and that&#8217;s mean I have to take the test in September or October so that I can start to looking for the universities in November and December ( I hope it&#8217;s not late ).</p>
<p>To tell you the truth, actually I feel a bit scared and not sure if my decision right now is the best. It&#8217;s just funny because I remembered that I was so sure about my plan to study abroad. I remembered how I convince my mother about my plan. At first she didn&#8217;t agree, she prefer that I continue my study in Singapore because she said it&#8217;s closer than Australia. But my father is different, he looks happy when I told him that I want to continue my study. I know that my father put so much faith in me, my sister told me that my father keep telling his friends about my plan to continue my study in Australia. From that I can conclude that he is hoping something big from me, I am happy to heard that and at the same time feel burdened because it&#8217;s all my choice to study abroad and my father give all the decision up to me. How if I can&#8217;t be what my father wanted me to be ? How if in the end I just ended up wasting his money ? </p>
<p>Maybe it&#8217;s just a pessimistic side of me, but after working for about one year and several months has made me questioned several things. The first is what I want to achieve and to do in this life. I keep asking my friends about this question : &#8220;What is the differences between you die now and later ?&#8221; Some said with the religious point in view in which he said that if you die now, you will ended up to a place that you shouldn&#8217;t been to. Others said that you can&#8217;t paid back for what your parents had gave to you, and there is also &#8216;confucius&#8217; alike opinion : &#8220;You must find it by yourself, as long as you keep living, you will find your purpose eventually&#8221;. </p>
<p>The second is about the reason why I should take my master degree and abroad. First time I decided to take the master degree is because I already completed my bachelor and I think it will be better if I can continue it to master. So simple, no particular reasons such as for getting good job or showing people that I have money to take my master degree. Time goes by, I started working, feels how to live by your own feet, see how other people struggling with their problems and realize how lucky I am. I am happy to be lucky, I am happy that I have a chance to continue my study abroad but it&#8217;s feels like taking another people luck. I am thinking at the moment that maybe I don&#8217;t deserve this, why not my sister ? why not my brother ? why me ? </p>
<p>The third is, let&#8217;s say I continue my study abroad, after wasting so much money and in the end I can&#8217;t pay back what I already wasted. One of my friend in my IELTS course said that if you decided to study abroad, don&#8217;t ever think to return to Indonesia before you can pay back what you had wasted. And it&#8217;s not included with the plan if I am getting married.</p>
<p>I think right now I just full of confusion, lack of planning, motivation, and reasons. So let&#8217;s living this life and wondering what surprise I&#8217;ll get next.</p>
<p><a href="http://blog.rudylee.com/2010/08/11/first-post-in-august-2010/">First post in August 2010</a> is a post from: <a href="http://blog.rudylee.com">SHARE Lifetime Experience</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rudylee.com/2010/08/11/first-post-in-august-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bookmark with Delicious</title>
		<link>http://blog.rudylee.com/2010/07/25/bookmark-with-delicious/</link>
		<comments>http://blog.rudylee.com/2010/07/25/bookmark-with-delicious/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 06:02:20 +0000</pubDate>
		<dc:creator>Rudy</dc:creator>
				<category><![CDATA[Reviews]]></category>

		<guid isPermaLink="false">http://blog.rudylee.com/?p=521</guid>
		<description><![CDATA[Have you ever heard about delicious ? no no, it&#8217;s not foods that are delicious but this Delicious. 
Delicious is a web application that allows to do the online bookmarking. If you say online that&#8217;s mean it&#8217;s not saved in your computer / laptop / server maybe. So if sometime you need to access your [...]<p><a href="http://blog.rudylee.com/2010/07/25/bookmark-with-delicious/">Bookmark with Delicious</a> is a post from: <a href="http://blog.rudylee.com">SHARE Lifetime Experience</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Have you ever heard about delicious ? no no, it&#8217;s not foods that are delicious but this <a href="http://www.delicious.com">Delicious</a>. </p>
<p>Delicious is a web application that allows to do the online bookmarking. If you say online that&#8217;s mean it&#8217;s not saved in your computer / laptop / server maybe. So if sometime you need to access your bookmark, you don&#8217;t have to open your computer or digging your old harddisk, just grab your friend&#8217;s computer, login to your Delicious and open the bookmark.</p>
<p>And what I like is it has the plugin for Firefox. It works just like the normal bookmark in Firefox ( using the same shortcut ctrl+D ) and it will automatically synchronize with the server. With that feature, if you bookmarked a website in your home computer, when you go to the office in the next morning and running Firefox at your office&#8217;s computer, the Delicious plugin will update all the bookmarks in your office&#8217;s computer. Surely it will happen vice versa.</p>
<p>The concept itself is simple, but the effect is so great. This online bookmark makes me don&#8217;t have to worry losing my bookmark in the future. </p>
<p>But just one thing that I think is missing. It doesn&#8217;t provides you with the capability to grouping the bookmarks. Actually it has, through tagging. But I want something more like a folder, so I can put something that are important to some special folder. But overall the current features already fulfill my needs at the moment. ( I don&#8217;t know if I have 1000 bookmark ) <img src='http://blog.rudylee.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><a href="http://blog.rudylee.com/2010/07/25/bookmark-with-delicious/">Bookmark with Delicious</a> is a post from: <a href="http://blog.rudylee.com">SHARE Lifetime Experience</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rudylee.com/2010/07/25/bookmark-with-delicious/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing OpenVZ and WebVZ in Centos 5.5</title>
		<link>http://blog.rudylee.com/2010/07/20/installing-openvz-and-webvz-in-centos-5-5/</link>
		<comments>http://blog.rudylee.com/2010/07/20/installing-openvz-and-webvz-in-centos-5-5/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 04:14:35 +0000</pubDate>
		<dc:creator>Rudy</dc:creator>
				<category><![CDATA[Unix dan Linux]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[containers]]></category>
		<category><![CDATA[grub]]></category>
		<category><![CDATA[instances]]></category>
		<category><![CDATA[kernels]]></category>
		<category><![CDATA[linux kernel]]></category>
		<category><![CDATA[management gui]]></category>
		<category><![CDATA[openvz]]></category>
		<category><![CDATA[operating system]]></category>
		<category><![CDATA[physical server]]></category>
		<category><![CDATA[repo]]></category>
		<category><![CDATA[repos]]></category>
		<category><![CDATA[repository]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[virtual environments]]></category>
		<category><![CDATA[virtual private servers]]></category>
		<category><![CDATA[web application]]></category>
		<category><![CDATA[wiki]]></category>
		<category><![CDATA[xen]]></category>
		<category><![CDATA[yum]]></category>

		<guid isPermaLink="false">http://blog.rudylee.com/?p=511</guid>
		<description><![CDATA[
OpenVZ is an operating system-level virtualization technology based on the Linux kernel and operating system. OpenVZ allows a physical server to run multiple isolated operating system instances, known as containers, Virtual Private Servers (VPSs), or Virtual Environments (VEs).

Now we&#8217;ll trying to install OpenVZ in Centos , because it&#8217;s an operating system-level so you need to [...]<p><a href="http://blog.rudylee.com/2010/07/20/installing-openvz-and-webvz-in-centos-5-5/">Installing OpenVZ and WebVZ in Centos 5.5</a> is a post from: <a href="http://blog.rudylee.com">SHARE Lifetime Experience</a></p>
]]></description>
			<content:encoded><![CDATA[<blockquote><p>
OpenVZ is an operating system-level virtualization technology based on the Linux kernel and operating system. OpenVZ allows a physical server to run multiple isolated operating system instances, known as containers, Virtual Private Servers (VPSs), or Virtual Environments (VEs).
</p></blockquote>
<p>Now we&#8217;ll trying to install OpenVZ in Centos , because it&#8217;s an operating system-level so you need to install it on top of Operating System ( if you are using hardware virtualization like Xen or VMware then you don&#8217;t have to install an Operating System ).</p>
<p>The first step is that you must install the Centos ( I am using Centos 5.5 ). I won&#8217;t explain about how to install it so you must find the tutorial yourself <img src='http://blog.rudylee.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>Let&#8217;s say you already installed the Centos, next step is updating your yum package manager. Here are the steps :</p>
<ul>
<li>Download the OpenVZ repo from http://download.openvz.org/openvz.repo</li>
<li>Put it in /etc/yum.repos.d directory</li>
<li>Run the yum update command</li>
</ul>
<p>Wait until the process is complete, it will downloading all the necessary update package. ( you can find the complete tutorial in <a href="http://wiki.openvz.org/Yum">OpenVZ Wiki</a> ).</p>
<p>Now we will install the OpenVZ, type this to install the OpenVZ :</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;">yum <span style="color: #c20cb9; font-weight: bold;">install</span> ovzkernel vzctl</pre></div></td></tr></table></div>

<p>If the installation running smooth you will have OpenVZ installed, reboot your machine :</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;">reboot</pre></div></td></tr></table></div>

<p>Press any key when the Grub screen is popping out. If it&#8217;s installed then you must have 3 kernels. Choose the top kernel ( it&#8217;s the OpenVZ kernel, in my machine it&#8217;s name is CentOS ( 2.6.18-194.3.1.el5.028stab069.6 ).</p>
<p>Log in to your machine as usual, now you are running on OpenVZ kernel. The next step is we will install WebVZ ( the OpenVZ management GUI ). The WebVZ, like it&#8217;s name, is a web application that runs on Ruby on Rails. So you must have Ruby on Rails in your machine to use the WebVZ.</p>
<p>To help us installing the Ruby on Rails we will use <a href="http://rubyworks.rubyforge.org/">Ruby Works </a>. Ruby Works is one of the CentOS repository that provides with the newest installer of Ruby, Gem and Rails.</p>
<p>Here are the steps :<br />
1.Download the repo file</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>rubyworks.rubyforge.org<span style="color: #000000; font-weight: bold;">/</span>RubyWorks.repo</pre></div></td></tr></table></div>

<p>2.Put it the file in the /etc/yum.repos.d<br />
3.yum update</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;">yum update</pre></div></td></tr></table></div>

<p>4.Installing the ruby packages</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;">yum <span style="color: #c20cb9; font-weight: bold;">install</span> ruby ruby-devel ruby-irb ruby-rdoc ruby-ri</pre></div></td></tr></table></div>

<p>5.Check the installed Ruby using this command ( it should print out the ruby version eg: ruby 1.8.6 )</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;">ruby <span style="color: #660033;">-v</span></pre></div></td></tr></table></div>

<p>6.Then download the latest gem at <a href="http://rubyforge.org/frs/?group_id=126">Rubyforge</a><br />
7.After download the latest gem, extract it, go the folder and run the installer</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;">ruby setup.rb</pre></div></td></tr></table></div>

<p>8.Check if the gem is installed successfully ( it should return the version too )</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #660033;">-v</span></pre></div></td></tr></table></div>

<p>9.Run the gem update to make sure the gem is up to date.</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;">gem update</pre></div></td></tr></table></div>

<p>10.Install the rails</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> rails <span style="color: #660033;">-v</span>=2.3.2</pre></div></td></tr></table></div>

<p>11.The WebVZ need sqlite to run, so you must install the sqlite and the gcc compiler</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;">yum <span style="color: #c20cb9; font-weight: bold;">install</span> sqlite-devel
yum <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">gcc</span> <span style="color: #c20cb9; font-weight: bold;">make</span></pre></div></td></tr></table></div>

<p>12.And the last is installing the sqlite for ruby</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> sqlite3-ruby <span style="color: #660033;">-v</span>=1.2.5</pre></div></td></tr></table></div>

<p>13.Download the <a href="http://webvz.sourceforge.net/download.html">WebVZ installer</a> from it&#8217;s website. Extract it and run the application.</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> webvz
ruby script<span style="color: #000000; font-weight: bold;">/</span>server</pre></div></td></tr></table></div>

<p>That&#8217;s all, then you can access it via web browser http://your-ip:3000. the username is admin and the password is admin123.</p>
<p>Update : ( run the WebVZ as daemon )<br />
to run WebVZ as daemon just go to it&#8217;s directory run this command instead of plain &#8220;ruby script/server&#8221;</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;">ruby script<span style="color: #000000; font-weight: bold;">/</span>server <span style="color: #000000; font-weight: bold;">&amp;&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000; font-weight: bold;">&amp;</span></pre></div></td></tr></table></div>

<p>and to make it&#8217;s run everytime you boot the machine ( put it in rc.local )</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh -e</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># rc.local</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># This script is executed at the end of each multiuser runlevel.</span>
<span style="color: #666666; font-style: italic;"># Make sure that the script will &quot;exit 0&quot; on success or any other</span>
<span style="color: #666666; font-style: italic;"># value on error.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># In order to enable or disable this script just change the execution</span>
<span style="color: #666666; font-style: italic;"># bits.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># By default this script does nothing.</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>webvz<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ruby script<span style="color: #000000; font-weight: bold;">/</span>server <span style="color: #000000; font-weight: bold;">&amp;&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000; font-weight: bold;">&amp;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></td></tr></table></div>

<p><a href="http://blog.rudylee.com/2010/07/20/installing-openvz-and-webvz-in-centos-5-5/">Installing OpenVZ and WebVZ in Centos 5.5</a> is a post from: <a href="http://blog.rudylee.com">SHARE Lifetime Experience</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rudylee.com/2010/07/20/installing-openvz-and-webvz-in-centos-5-5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Eclipse Democamps 2010</title>
		<link>http://blog.rudylee.com/2010/07/11/eclipse-democamps-2010-2/</link>
		<comments>http://blog.rudylee.com/2010/07/11/eclipse-democamps-2010-2/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 07:18:53 +0000</pubDate>
		<dc:creator>Rudy</dc:creator>
				<category><![CDATA[Featured Articles]]></category>
		<category><![CDATA[My Stories]]></category>
		<category><![CDATA[acara]]></category>
		<category><![CDATA[arigatou]]></category>
		<category><![CDATA[bapak]]></category>
		<category><![CDATA[bincang]]></category>
		<category><![CDATA[bulat]]></category>
		<category><![CDATA[datang ke]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[jalan jalan]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[karyawan]]></category>
		<category><![CDATA[kesal]]></category>
		<category><![CDATA[kira kira]]></category>
		<category><![CDATA[kosan]]></category>
		<category><![CDATA[lanjut]]></category>
		<category><![CDATA[maaf]]></category>
		<category><![CDATA[nekat]]></category>
		<category><![CDATA[parkir]]></category>
		<category><![CDATA[persis]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ping pong]]></category>
		<category><![CDATA[posisi]]></category>
		<category><![CDATA[riani]]></category>
		<category><![CDATA[ribet]]></category>
		<category><![CDATA[senang]]></category>
		<category><![CDATA[sudirman]]></category>
		<category><![CDATA[yah]]></category>

		<guid isPermaLink="false">http://blog.rudylee.com/?p=498</guid>
		<description><![CDATA[Kemarin tanggal 10 Juli 2010 gwa baru saja ikut Eclipse Democamps 2010. Yah sebenarnya gwa ga tau ini termasuk seminar, meet up atau promosi eclipse tapi berhubung gwa adalah pengguna Eclipse semenjak beberapa bulan lalu maka gwa iseng-iseng datang ke acara ini.
Perjalanan dimulai dari kosan gwa dengan ditemani sang kekasih yaitu adinda Riani yang imut [...]<p><a href="http://blog.rudylee.com/2010/07/11/eclipse-democamps-2010-2/">Eclipse Democamps 2010</a> is a post from: <a href="http://blog.rudylee.com">SHARE Lifetime Experience</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Kemarin tanggal 10 Juli 2010 gwa baru saja ikut Eclipse Democamps 2010. Yah sebenarnya gwa ga tau ini termasuk seminar, meet up atau promosi eclipse tapi berhubung gwa adalah pengguna Eclipse semenjak beberapa bulan lalu maka gwa iseng-iseng datang ke acara ini.</p>
<p>Perjalanan dimulai dari kosan gwa dengan ditemani sang kekasih yaitu adinda <a href="http://maroonluph.wordpress.com">Riani</a> yang imut dan bulat seperti bola ping pong ( nyungsep dolo sebelum kena granat ). Sebenarnya kami rada telat berangkatnya ( kira-kira jam 9:30 ) sementara acaranya jam 10:00 dan ditambah lagi gwa dan riani ga tau jalan sekali kesana.</p>
<p>Dibekali dengan insting hewani maka kami nekat berangkat dan ternyata berakhir dengan muter-muter di sudirman. Sebenarnya gwa tau persis itu posisi gedung stock exchange ( setelah dikasih tau riani ) tapi emang jalan sudirman kalau mau muter balik rada ribet jadi berakhir lah kami jalan-jalan hampir setengah jalan sudirman. ( bagi yang sudah lama malang melintang di jalan sudirman pasti sudah tau la )</p>
<p>Setelah sampai tempat parkir motor adinda Riani sempat merasa kesal gara-gara kami rada telat sampenya ( kira-kira jam 10:18 ) dan sepertinya kami salah markir motor. Tapi ternyata setelah kami tanya ke satpam yang bertugas ternyata kami tidak salah parkir motor dan gedung stock exchangenya berada di sebelah tempat kami parkir motor ( dan riani yang tadi kesel seperti mesin diesel berubah menjadi senang seperti mesin benang ).</p>
<div id="attachment_503" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.rudylee.com/wp-content/uploads/2010/07/cemberut2.jpg"><img src="http://blog.rudylee.com/wp-content/uploads/2010/07/cemberut2-300x264.jpg" alt="Gambar Riani Cemberut" title="Gambar Riani Cemberut" width="300" height="264" class="size-medium wp-image-503" /></a><p class="wp-caption-text">Gambar Riani Cemberut</p></div>
<p>Cukup cerita tentang masalah dalam negeri, kita lanjut dengan cerita tentang acaranya. Ketika kami datang ternyata acaranya belum dimulai dan yang datang kok lebih sedikit dari yang diperkirakan ( kira-kira ada 30 orang saja ). Saat itu ada seorang bapak dari microsoft tengah berbincang-bincang dengan para peserta ( maaf ya pak saya lupa nama bapak ) &#8211;> setelah dikasih tau ternyata nama bapaknya Risman Adnan.</p>
<p>Dari perbincangan singkat bapak itu, gwa dapat menarik kesimpulan bahwa ternyata sang bapak kerja di microsoft ( ya iyalah ) dan dalam perbincangan singkat, bapak tersebut meng-encourage para peserta agar bisa buka bisnis sendiri serta tidak mempunyai mental karyawan. ( si bapak banyak menceritakan keluh kesahnya jika umur sudah tua, punya anak dan &#8220;gampang&#8221;nya buka bisnis )</p>
<p>Selesai dengan seminar motivasinya ( arigatou bapak microsoft ) kemudian dilanjutkan dengan acara intinya. Acara pertama dimulai dengan presentasi cara mengintegrasikan Eclipse Helios dengan Team Foundation Server ( version control punya microsoft ) yang dibawakan oleh pak <a href="http://netindonesia.net/blogs/ronald/">Ronald Rajagukguk</a>. Namun dikarenakan gwa sudah jatuh cinta dengan <a href="http://git-scm.com/">Git</a> maka gwa ga gitu tertarik untuk mencobanya, tapi lumayan buat tambah ilmunya ( terima kasih pak <a href="http://netindonesia.net/blogs/ronald/">Ronald Rajagukguk</a> dari microsoft atas ilmunya).</p>
<p>Selesai makan siang baru dilanjutkan lagi dengan presentasi tentang Eclipse Helios yang dibawakan oleh pak <a href="http://frans.thamura.info/">Frans Thamura</a> dari Meruvian Foundation. Presentasi yang dibawakan oleh pak Frans termasuk singkat dan lebih banyak &#8220;belajar sendirinya&#8221;. Dan dari presentasi &#8220;belajar sendiri&#8221; ala pak Frans maka yang bisa gwa simpulkan adalah : </p>
<blockquote><p>
Eclipse Helios ga berbeda jauh dengan Galileo tapi ada tambahan fitur market placenya ( udah kek main age of empire aja pake market ) dan fitur-fitur lainnya yang tidak sempat dijelaskan.
</p></blockquote>
<p>Setelah presentasi &#8220;belajar sendiri&#8221;, acara dilanjutkan dengan presentasi tentang Android dengan menggunakan Eclipse dan ditutup dengan presentasi tentang BlueOxygen yang &#8216;kayaknya&#8217; merupakan sebuah IDE yang memungkinkan kita membuat design UI Java seperti di VB ( wah cocok buat gwa yang baru mo pegang Java).</p>
<p>Overall menurut gwa acaranya cukup asik karena tempatnya enak ( microsoft gitu loh ), dapat makan ( padahal gwa ampir desperate mo cari makan dimana ), dapat ceramah tentang pandangan orang-orang yang lebih berpengalaman di dunia IT terutama bertemu dengan pak Frans Thamura.</p>
<p>Secara pribadi gwa belum pernah ikut seminar, meet up atau acara-acara open source lainnya. Salah satu acara open source yang selama ini ingin gwa ikutin adalah <a href="http://cakefest.org/">CakeFest</a> ( semacam seminar tentang CakePHP Framework). Tapi apa daya, uang ga punya, acaranya jauh di chicago jadi terpaksa mencari-cari konferensi PHP yang dekat.</p>
<div id="attachment_501" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.rudylee.com/wp-content/uploads/2010/07/cakefest_berlin_offwhite_huge.png"><img src="http://blog.rudylee.com/wp-content/uploads/2010/07/cakefest_berlin_offwhite_huge-300x123.png" alt="Cake Festival" title="Cake Festival" width="300" height="123" class="size-medium wp-image-501" /></a><p class="wp-caption-text">Cake Festival</p></div>
<p>Tetapi sejauh mata memandang gwa belum pernah menemukan konferensi PHP atau meet up PHP di Jakarta khususnya yang membahas tentang advance teknologi PHP ( yah kalau basic PHP, Joomla, Drupal, Wordpress mungkin banyak ya ). Gwa sih pengennya ngumpul-ngumpul dan omongin tentang teknologi PHP yang terbaru seperti PHP 5.3, fitur namespacenya, Unit Test, Test Driven Development, NoSQL database seperti Mongo dan Couch, framework-framework lainnya.</p>
<p>Jadi gwa cukup salut dengan pak frans yang mungkin dapat dikatakan &#8220;gila&#8221; dengan Open Sourcenya dan berusaha menebarkan kegilaan tersebut melalui komunitas-komunitas yang dia buat. Sementara gwa disini hanya menunggu orang-orang untuk membuat sebuah komunitas dan mempertanyakan kenapa tidak ada komunitas seperti itu, tapi di sisi lain pak Frans malah giat membuat komunitas-komunitas ( bagus pak, tingkatkan terus perjuangan bapak. saya ikutin saja dari belakang <img src='http://blog.rudylee.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  ). Jadi sekarang saatnya mencari-cari PHP conference di Jakarta <img src='http://blog.rudylee.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://blog.rudylee.com/2010/07/11/eclipse-democamps-2010-2/">Eclipse Democamps 2010</a> is a post from: <a href="http://blog.rudylee.com">SHARE Lifetime Experience</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rudylee.com/2010/07/11/eclipse-democamps-2010-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Updating ports in FreeBSD 8.0</title>
		<link>http://blog.rudylee.com/2010/06/28/updating-ports-in-freebsd-8-0/</link>
		<comments>http://blog.rudylee.com/2010/06/28/updating-ports-in-freebsd-8-0/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 05:12:33 +0000</pubDate>
		<dc:creator>Rudy</dc:creator>
				<category><![CDATA[Unix dan Linux]]></category>
		<category><![CDATA[application folder]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[mirror]]></category>
		<category><![CDATA[ports]]></category>
		<category><![CDATA[repository]]></category>
		<category><![CDATA[several ways]]></category>
		<category><![CDATA[share examples]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.rudylee.com/?p=493</guid>
		<description><![CDATA[Ports is the applications repository in FreeBSD. Unlike Ubuntu that provides you with command &#8220;apt-get&#8221;, in FreeBSD you must manually go to the application folder in &#8220;/usr/ports&#8221; ( the folder where Ports remain ) and search for the application that you want to install. But what&#8217;s the differences between you compile it yourself and using [...]<p><a href="http://blog.rudylee.com/2010/06/28/updating-ports-in-freebsd-8-0/">Updating ports in FreeBSD 8.0</a> is a post from: <a href="http://blog.rudylee.com">SHARE Lifetime Experience</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Ports is the applications repository in FreeBSD. Unlike Ubuntu that provides you with command &#8220;apt-get&#8221;, in FreeBSD you must manually go to the application folder in &#8220;/usr/ports&#8221; ( the folder where Ports remain ) and search for the application that you want to install. But what&#8217;s the differences between you compile it yourself and using ports. The answer is &#8220;dependencies&#8221;.</p>
<p>Enough with the introduction, let&#8217;s go the main topic. So we are going to update the Ports using cvsup. Yeah&#8230; yeah&#8230; I know that there are several ways to update the ports, but I prefer to use cvsup ( because it&#8217;s the way I taught ). The steps are :<br />
1.Install the cvsup</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;">pkg_add <span style="color: #660033;">-vr</span> cvsup-without-gui</pre></div></td></tr></table></div>

<p>2.Copy the ports-supfile from example</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>examples<span style="color: #000000; font-weight: bold;">/</span>cvsup<span style="color: #000000; font-weight: bold;">/</span>ports-supfile .</pre></div></td></tr></table></div>

<p>3.Rehash</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;">rehash</pre></div></td></tr></table></div>

<p>4.Edit the ports-supfile, find the line that say CHANGETHIS.FreeBSD.org. Change it with the mirror that is near you ( I am using BizNet )</p>
<p>5.Run the ports-supfile using cvsup</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;">cvsup <span style="color: #660033;">-g</span> <span style="color: #660033;">-L</span> <span style="color: #000000;">2</span> ports-supfile</pre></div></td></tr></table></div>

<p>Wait until the process is complete and your ports will be updated.</p>
<p><a href="http://blog.rudylee.com/2010/06/28/updating-ports-in-freebsd-8-0/">Updating ports in FreeBSD 8.0</a> is a post from: <a href="http://blog.rudylee.com">SHARE Lifetime Experience</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rudylee.com/2010/06/28/updating-ports-in-freebsd-8-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Copying files between 2 unix servers</title>
		<link>http://blog.rudylee.com/2010/06/08/copying-files-between-2-unix-servers/</link>
		<comments>http://blog.rudylee.com/2010/06/08/copying-files-between-2-unix-servers/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 04:34:02 +0000</pubDate>
		<dc:creator>Rudy</dc:creator>
				<category><![CDATA[Unix dan Linux]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[ksh]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://blog.rudylee.com/?p=489</guid>
		<description><![CDATA[There are many solutions to copying files between 2 unix servers, such as :

Copying the files from your unix server to your local machine, and then upload the files to the destination server.
Using NFS to share the files from your source server to your destination server.
Using FTP to copy the files.

First solution is recommended if [...]<p><a href="http://blog.rudylee.com/2010/06/08/copying-files-between-2-unix-servers/">Copying files between 2 unix servers</a> is a post from: <a href="http://blog.rudylee.com">SHARE Lifetime Experience</a></p>
]]></description>
			<content:encoded><![CDATA[<p>There are many solutions to copying files between 2 unix servers, such as :</p>
<ul>
<li>Copying the files from your unix server to your local machine, and then upload the files to the destination server.</li>
<li>Using NFS to share the files from your source server to your destination server.</li>
<li>Using FTP to copy the files.</li>
</ul>
<p>First solution is recommended if your files are not much and small in sizes. But if your files are big, then you must provide big storage in your local machine.  Using NFS can be an alternate solution, it&#8217;s easy to set up, easy to mounting the directory and easy to copy the files. But sometimes there are some issues with the NFS, so must carefully in using NFS.</p>
<p>The last solution is using FTP. Maybe you are wondering &#8220;How can I copy between 2 unix servers using FTP ? Do I have to copy it to local machine first ? &#8220;, actually you don&#8217;t have to, because there is a technology called &#8216;XFTP&#8217;. They said that you can open 2 Unix Server in different window and copy between that two machines. But I haven&#8217;t tested that yet.</p>
<p>Another way is using &#8220;self made script&#8221; in which I don&#8217;t create it myself, I copied it from <a href="http://www.unix.com/shell-programming-scripting/9174-recursive-ftp-here-last.html">here</a>. The script allows you to connect to a ftp server, get all the the content of that ftp server and it&#8217;s all in terminal ( no GUI, no drag and drop, just bash command ). The script also provides you with several options ( you can get the content of specific folder in the ftp server ).</p>
<p>Here is the complete script in case the website is down :</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#! /usr/bin/ksh</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  HardFeed  --  Harvest A Remote Directory via</span>
<span style="color: #666666; font-style: italic;">#                Ftp Enhanced Exhaustive Duplication</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  Perderabo  11-23-02</span>
&nbsp;
<span style="color: #007800;">VERSION</span>=<span style="color: #ff0000;">&quot;1.1&quot;</span>    <span style="color: #666666; font-style: italic;"># 03-16-04</span>
&nbsp;
<span style="color: #007800;">USAGE</span>=<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\
</span>HardFeed [ -v | -s | -d | -r | -f | -m | -p password-file 
           -l list-command | -x ftp-command ...  ] system user [directory]
&nbsp;
use <span style="color: #000099; font-weight: bold;">\&quot;</span>HardFeed -h<span style="color: #000099; font-weight: bold;">\&quot;</span> use for more documentation
&nbsp;
-v (verbose)  Print stuff during run
-s (symlink)  Attempt to duplicate any remote symlinks
-d (directory)Attempt to duplicate any remote directories
-r (recurse)  Attempt to descend into any directories and process them
-f (freshen)  If remote file is newer than local file, overwrite the local 
-m (mode)     Attempt a chmod on files and directories that we create
-p (password) Specify a file that contains the password in plaintext
-x (extra)    Specify a command to be sent to the ftp client 
-l (listcmd)  Override the choice of <span style="color: #000099; font-weight: bold;">\&quot;</span>ls .<span style="color: #000099; font-weight: bold;">\&quot;</span> to get a remote directory&quot;</span>
&nbsp;
<span style="color: #007800;">DOCUMENTATION</span>=<span style="color: #ff0000;">&quot;HardFeed  Version <span style="color: #007800;">$VERSION</span>
&nbsp;
<span style="color: #007800;">$USAGE</span>
&nbsp;
HardFeed copies all of the contents of a remote directory to the current 
directory using ftp.  It establishes an ftp connection to the remote 
site and it uses the ftp command <span style="color: #000099; font-weight: bold;">\&quot;</span>ls<span style="color: #000099; font-weight: bold;">\&quot;</span> to get a listing of the remote
directory.  The two required parameters are the remote sytstem and the user
name.  The optional third parameter is the remote directory to copy.  The 
default is just the home directory of the ftp account.
&nbsp;
HardFeed will prompt you for the password.  This is very secure but it isn't
any good if you want to run HardFeed automatically. You can set the password in
the environment variable HARDFEED_P as an alternate.  HardFeed will set an
internal variable to the password and then clobber the variable HARDFEED_P,
since on some systems, the environment of another process can be displayed.
With most shells, you can also set an environment variable for one command
only, like this: <span style="color: #000099; font-weight: bold;">\&quot;</span>HARDFEED_P=xyzzy HardFeed -dR ftpxy joeblow sourcedir<span style="color: #000099; font-weight: bold;">\&quot;</span>. 
A second alternative is to specify a <span style="color: #000099; font-weight: bold;">\&quot;</span>password file<span style="color: #000099; font-weight: bold;">\&quot;</span> with the -p option.  
Such a file contains, in plaintext, the password.  HardFeed will read the file
to get the password.  You must decide which option makes more sense in your
environment.
&nbsp;
Only files are examined.  If we don't have a copy of the remote file, we 
will get it.  HardFeed will never overwrite an existing file system object
with one exception.  If you specify -f and we have both a remote file and a
local file, the timestamps are compared.  If the remote file is newer, a
retrieval attempt will be made.  The local file must be writable for this
to succeed.  For the timestamp compare to work, you and the remote system
must be in the same timezone.  (You can vary your environment to make this
true.)
&nbsp;
Normally symbolic links are ignored. But with -s, we will attempt to create
a symlink with the same link data.  Even with -s, we will never overwrite
any existing object with a new symbolic link.  You will need to review any
symlinks created and probably correct them.  
&nbsp;
Normally, directories are ignored.  If you specify -d, HardFeed will attempt
to create the directory locally.  But again, it will never overwrite an
existing object to create a directory.  If you specify -r, HardFeed will 
attempt to recurse into a directory and process all of the files there.  If
you use both -d and -r, it will copy an entire directory hierarchy.  But you
can leave off -d and only pre-create a few directories if you want.
&nbsp;
HardFeed will attempt a chmod of any file or directory that it creates if you 
specify -m.  It will try to match the mode of the remote object.
&nbsp;
HardFeed operates by establishing a co-process to the ftp command.  Normally,
the output from the co-process is sent to an un-named file in /tmp and
discarded.  If you want to capture this output, connect a file to fd 3 and
HardFeed will use it for this purpose.  From ksh the syntax is 3&gt;file.  You 
can also do 3&gt;&amp;1 to see it real time during the run if you really want.
&nbsp;
You can make HardFeed send the ftp co-process some extra commands after the
connection is established with -x.  
&nbsp;
HardFeed gets a directory listing by sending a <span style="color: #000099; font-weight: bold;">\&quot;</span>ls .<span style="color: #000099; font-weight: bold;">\&quot;</span> command to the server.
Some servers will list dot files with this while others won't.  You can use the
-l option to change the command if your server needs a different one to do want
you want. -l <span style="color: #000099; font-weight: bold;">\&quot;</span>ls -al<span style="color: #000099; font-weight: bold;">\&quot;</span> is one example that I got to work with unix.
&nbsp;
For a microsoft ftp server, I had some luck with:
 -l <span style="color: #000099; font-weight: bold;">\&quot;</span>ls -la<span style="color: #000099; font-weight: bold;">\&quot;</span> -x <span style="color: #000099; font-weight: bold;">\&quot;</span>quote site dirstyle<span style="color: #000099; font-weight: bold;">\&quot;</span>
Note that everything is transferred in binary mode.  -x ascii will switch
everything to ascii mode.  HardFeed supports embedded spaces in filenames.  User
names may be long and contain slashes. All of this may make it somewhat usable 
with microsoft ftp servers.&quot;</span>
&nbsp;
&nbsp;
<span style="color: #007800;">IFS</span>=<span style="color: #ff0000;">&quot;&quot;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  If the password is coming in via the environment, save it in</span>
<span style="color: #666666; font-style: italic;">#  a local variable and then clobber the environment variable</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">unset</span> PASSWORD
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #007800;">$HARDFEED_P</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #007800;">PASSWORD</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HARDFEED</span>-P&quot;</span>
	<span style="color: #007800;">HARDFEED_P</span>=<span style="color: #ff0000;">'********'</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  Parse Command Line</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-A</span> OPT_CMDS_LIST
<span style="color: #007800;">OPT_DIRCMD</span>=<span style="color: #ff0000;">&quot;ls .&quot;</span>
<span style="color: #007800;">OPT_VERBOSE</span>=<span style="color: #000000;">0</span>
<span style="color: #007800;">OPT_SYMLINKS</span>=<span style="color: #000000;">0</span>
<span style="color: #007800;">OPT_DIRECTORIES</span>=<span style="color: #000000;">0</span>
<span style="color: #007800;">OPT_RECURS</span>=<span style="color: #000000;">0</span>
<span style="color: #007800;">OPT_FRESHEN</span>=<span style="color: #000000;">0</span>
<span style="color: #007800;">OPT_MODE</span>=<span style="color: #000000;">0</span>
<span style="color: #007800;">OPT_PASSWORDFILE</span>=<span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #007800;">OPT_CMDS</span>=<span style="color: #000000;">0</span>
<span style="color: #007800;">error</span>=<span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">getopts</span> :vsdrfmhp:x:l:  o ; <span style="color: #000000; font-weight: bold;">do</span>
	<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #007800;">$o</span> <span style="color: #000000; font-weight: bold;">in</span>
	v<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">OPT_VERBOSE</span>=<span style="color: #000000;">1</span>
		<span style="color: #000000; font-weight: bold;">;;</span>
        s<span style="color: #7a0874; font-weight: bold;">&#41;</span>      <span style="color: #007800;">OPT_SYMLINKS</span>=<span style="color: #000000;">1</span>
		<span style="color: #000000; font-weight: bold;">;;</span>
        d<span style="color: #7a0874; font-weight: bold;">&#41;</span>      <span style="color: #007800;">OPT_DIRECTORIES</span>=<span style="color: #000000;">1</span>
                <span style="color: #000000; font-weight: bold;">;;</span>
	r<span style="color: #7a0874; font-weight: bold;">&#41;</span>      <span style="color: #007800;">OPT_RECURS</span>=<span style="color: #000000;">1</span>
		<span style="color: #000000; font-weight: bold;">;;</span>
	f<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">OPT_FRESHEN</span>=<span style="color: #000000;">1</span>
		<span style="color: #000000; font-weight: bold;">;;</span>
	m<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">OPT_MODE</span>=<span style="color: #000000;">1</span>
		<span style="color: #000000; font-weight: bold;">;;</span>
	h<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DOCUMENTATION</span>&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
		<span style="color: #000000; font-weight: bold;">;;</span>
	p<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">OPT_PASSWORDFILE</span>=<span style="color: #007800;">$OPTARG</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$OPT_PASSWORDFILE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> error <span style="color: #007800;">$OPT_PASSWORDFILE</span> is not a <span style="color: #c20cb9; font-weight: bold;">file</span>
			<span style="color: #007800;">error</span>=<span style="color: #000000;">1</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
		<span style="color: #000000; font-weight: bold;">;;</span>
	x<span style="color: #7a0874; font-weight: bold;">&#41;</span>	OPT_CMDS_LIST<span style="color: #7a0874; font-weight: bold;">&#91;</span>OPT_CMDS<span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$OPTARG</span>&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">OPT_CMDS</span>=OPT_CMDS+<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #000000; font-weight: bold;">;;</span>
	l<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">OPT_DIRCMD</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$OPTARG</span>&quot;</span>
		<span style="color: #000000; font-weight: bold;">;;</span>
	?<span style="color: #7a0874; font-weight: bold;">&#41;</span>      print error argument <span style="color: #007800;">$OPTARG</span> is illegal
		<span style="color: #007800;">error</span>=<span style="color: #000000;">1</span>
		<span style="color: #000000; font-weight: bold;">;;</span>
	<span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">shift</span> OPTIND-<span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>error<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$USAGE</span>&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">2</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #007800;">$#</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">3</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$USAGE</span>&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #007800;">SYSTEM</span>=$<span style="color: #000000;">1</span>
<span style="color: #007800;">USER</span>=$<span style="color: #000000;">2</span>
<span style="color: #007800;">DIRECTORY</span>=$<span style="color: #000000;">3</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #007800;">$DIRECTORY</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #007800;">DIRECTORY</span>=.
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  Read password file if one is supplied</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #007800;">$OPT_PASSWORDFILE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #c20cb9; font-weight: bold;">read</span> PASSWORD <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #007800;">$OPT_PASSWORDFILE</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  Request password if it didn't come in via env or file</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #007800;">$PASSWORD</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
	print <span style="color: #660033;">-n</span> password -
	<span style="color: #c20cb9; font-weight: bold;">stty</span> <span style="color: #660033;">-echo</span>
	<span style="color: #c20cb9; font-weight: bold;">read</span> PASSWORD
	<span style="color: #7a0874; font-weight: bold;">echo</span>
	<span style="color: #c20cb9; font-weight: bold;">stty</span> <span style="color: #7a0874; font-weight: bold;">echo</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  FD 3 will be the transcript of the ftp co-process.  If the user</span>
<span style="color: #666666; font-style: italic;">#  supplied a file for this, we will use that.  Otherwise it will go</span>
<span style="color: #666666; font-style: italic;">#  to a nameless file in /tmp</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> print <span style="color: #660033;">-u3</span> <span style="color: #ff0000;">&quot; Transcript of the ftp co-process for HardFeed&quot;</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null ; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #007800;">LOGFILE</span>=<span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #007800;">LOGFILE</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>HardFeed.log.<span style="color: #007800;">$$</span>
	<span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #007800;">$LOGFILE</span>
	<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #007800;">$LOGFILE</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  Max time to wait for arrivial of file.  This is a long time.  During</span>
<span style="color: #666666; font-style: italic;">#  an interactive run, the user can use SIGINT if it seems to be taking</span>
<span style="color: #666666; font-style: italic;">#  too long.  This max is intended to assure that a cron job will not</span>
<span style="color: #666666; font-style: italic;">#  hang forever.</span>
&nbsp;
<span style="color: #007800;">OPT_MAXWAIT</span>=<span style="color: #000000;">15</span>
<span style="color: #007800;">TIMEOUT</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>HardFeed.timeout.<span style="color: #007800;">$$</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  Various other initializations</span>
&nbsp;
<span style="color: #007800;">LEV</span>=<span style="color: #000000;">0</span>
<span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #ff0000;">&quot;+%Y %m&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #007800;">IFS</span>=<span style="color: #ff0000;">&quot; &quot;</span> <span style="color: #c20cb9; font-weight: bold;">read</span> THISYEAR THISMONTH
<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">LASTYEAR</span>=THISYEAR-<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">STARTPATH</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">pwd</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-A</span> DIR_FILE_NAME
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-A</span> DIR_LINE_NUM
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  Function to convert month to numeric</span>
&nbsp;
conv_month<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #7a0874; font-weight: bold;">typeset</span> <span style="color: #660033;">-l</span> month
	<span style="color: #007800;">month</span>=$<span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #007800;">$month</span> <span style="color: #000000; font-weight: bold;">in</span>
	jan<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">nmonth</span>=<span style="color: #000000;">1</span>  <span style="color: #000000; font-weight: bold;">;;</span>
	feb<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">nmonth</span>=<span style="color: #000000;">2</span>  <span style="color: #000000; font-weight: bold;">;;</span>
	mar<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">nmonth</span>=<span style="color: #000000;">3</span>  <span style="color: #000000; font-weight: bold;">;;</span>
	apr<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">nmonth</span>=<span style="color: #000000;">4</span>  <span style="color: #000000; font-weight: bold;">;;</span>
	may<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">nmonth</span>=<span style="color: #000000;">5</span>  <span style="color: #000000; font-weight: bold;">;;</span>
	jun<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">nmonth</span>=<span style="color: #000000;">6</span>  <span style="color: #000000; font-weight: bold;">;;</span>
	jul<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">nmonth</span>=<span style="color: #000000;">7</span>  <span style="color: #000000; font-weight: bold;">;;</span>
	aug<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">nmonth</span>=<span style="color: #000000;">8</span>  <span style="color: #000000; font-weight: bold;">;;</span>
	sep<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">nmonth</span>=<span style="color: #000000;">9</span>  <span style="color: #000000; font-weight: bold;">;;</span>
	oct<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">nmonth</span>=<span style="color: #000000;">10</span> <span style="color: #000000; font-weight: bold;">;;</span>
	nov<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">nmonth</span>=<span style="color: #000000;">11</span> <span style="color: #000000; font-weight: bold;">;;</span>
	dec<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">nmonth</span>=<span style="color: #000000;">12</span> <span style="color: #000000; font-weight: bold;">;;</span>
	<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">nmonth</span>=<span style="color: #000000;">0</span>  <span style="color: #000000; font-weight: bold;">;;</span>
	<span style="color: #000000; font-weight: bold;">esac</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$nmonth</span>
	<span style="color: #7a0874; font-weight: bold;">return</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">!</span>nmonth<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Function to determine if a file system object exists</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># neither -a nor -e is really portable  8(</span>
&nbsp;
exists<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> $<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #660033;">-d</span> $<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #660033;">-L</span> $<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #660033;">-p</span> $<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #660033;">-S</span> $<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #660033;">-b</span> $<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #660033;">-c</span> $<span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #007800;">$?</span>
	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Function to wait for a file to arrive</span>
&nbsp;
waitfor<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #007800;">wanted</span>=$<span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>OPT_MAXWAIT<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">GIVEUP</span>=SECONDS+OPT_MAXWAIT<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #007800;">GIVEUP</span>=<span style="color: #ff0000;">&quot;-1&quot;</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">while</span> 	<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$wanted</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #007800;">$SECONDS</span> <span style="color: #660033;">-lt</span> <span style="color: #007800;">$GIVEUP</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">do</span>
		<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">done</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$wanted</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;FATAL ERROR:&quot;</span> timed out waiting <span style="color: #000000; font-weight: bold;">for</span>:  <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;            &quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$wanted</span>&quot;</span>               <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> 
		print <span style="color: #660033;">-p</span> bye  <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
		<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  Function to decode an &quot;ls -l&quot; line.</span>
&nbsp;
lsdcode<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
&nbsp;
	<span style="color: #7a0874; font-weight: bold;">typeset</span> <span style="color: #660033;">-Z2</span> nmonth day
	<span style="color: #7a0874; font-weight: bold;">typeset</span> <span style="color: #660033;">-i8</span> octal
&nbsp;
	<span style="color: #666666; font-style: italic;">#</span>
	<span style="color: #666666; font-style: italic;">#  get the line, get the first character, split line into words</span>
&nbsp;
	<span style="color: #007800;">line</span>=<span style="color: #ff0000;">&quot;$1&quot;</span>
	<span style="color: #007800;">char1</span>=<span style="color: #800000;">${line%%${line#?}</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>
	<span style="color: #007800;">IFS</span>=<span style="color: #ff0000;">&quot; &quot;</span>
	<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-A</span>  things <span style="color: #660033;">--</span> <span style="color: #007800;">$line</span>
	<span style="color: #007800;">IFS</span>=<span style="color: #ff0000;">&quot;&quot;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">#</span>
	<span style="color: #666666; font-style: italic;">#  We may have a &quot;total&quot; line which needs to be ignored</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${things[0]}</span> = total <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-A</span>  lsdc <span style="color: #660033;">--</span>  skip 000 000000000000 x x
		<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">#</span>
	<span style="color: #666666; font-style: italic;">#</span>
	<span style="color: #007800;">parser</span>=<span style="color: #000000;">1</span>
	<span style="color: #007800;">month</span>=<span style="color: #800000;">${things[5]}</span>
	<span style="color: #007800;">xmonth</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>conv_month <span style="color: #007800;">$month</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">if</span>  conv_month <span style="color: #007800;">$month</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null ; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #007800;">parser</span>=<span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #007800;">parser</span>=<span style="color: #000000;">0</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>parser<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #666666; font-style: italic;">#</span>
		<span style="color: #666666; font-style: italic;"># Strict Left to Right Parse Routine </span>
		<span style="color: #666666; font-style: italic;">#</span>
		<span style="color: #666666; font-style: italic;"># Break out the fields that we want.  This technique requires</span>
		<span style="color: #666666; font-style: italic;"># that the user, group, and size fields never run together and</span>
		<span style="color: #666666; font-style: italic;"># so they must have at least one space between them.  But it </span>
		<span style="color: #666666; font-style: italic;"># allows some limited support of filenames with embedded spaces.</span>
&nbsp;
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$line</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #007800;">IFS</span>=<span style="color: #ff0000;">&quot; &quot;</span> <span style="color: #c20cb9; font-weight: bold;">read</span> permstring junk junk junk junk \
						month day swing rawname
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$char1</span> = l <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">link</span></span>=<span style="color: #800000;">${rawname#*-\&gt; }</span>
			<span style="color: #007800;">name</span>=<span style="color: #800000;">${rawname% -\&gt;*}</span>
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #007800;">name</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$rawname</span>&quot;</span>
			<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">link</span></span>=<span style="color: #ff0000;">&quot;&quot;</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #666666; font-style: italic;">#</span>
		<span style="color: #666666; font-style: italic;"># Outside to Inside Parse Routine </span>
		<span style="color: #666666; font-style: italic;">#</span>
		<span style="color: #666666; font-style: italic;"># Break out the fields that we want.  This technique requires </span>
		<span style="color: #666666; font-style: italic;"># that no white space exist in the filename.  But the user, </span>
		<span style="color: #666666; font-style: italic;"># group, and size  fields may sometimes run together without </span>
		<span style="color: #666666; font-style: italic;"># causing a problem.</span>
&nbsp;
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;WARNING:&quot;</span> badly formatted line <span style="color: #000000; font-weight: bold;">in</span> directory listing <span style="color: #000000; font-weight: bold;">for</span>:    <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;        &quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${line}</span>&quot;</span>                                         <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;        &quot;</span> attempting outside-to-inside scan                 <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span>                                                              <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
&nbsp;
		<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">pname</span>=<span style="color: #800000;">${#things[*]}</span>-<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$char1</span> = l <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">link</span></span>=<span style="color: #800000;">${things[pname]}</span>
			<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">pname</span>=pname-<span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">link</span></span>=
		<span style="color: #000000; font-weight: bold;">fi</span>
		<span style="color: #007800;">permstring</span>=<span style="color: #800000;">${things[0]}</span>
		<span style="color: #007800;">name</span>=<span style="color: #800000;">${things[pname]}</span>
		<span style="color: #007800;">month</span>=<span style="color: #800000;">${things[pname-3]}</span>
		<span style="color: #007800;">day</span>=<span style="color: #800000;">${things[pname-2]}</span>
		<span style="color: #007800;">swing</span>=<span style="color: #800000;">${things[pname-1]}</span>
		<span style="color: #000000; font-weight: bold;">if</span>  conv_month <span style="color: #007800;">$month</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null ; <span style="color: #000000; font-weight: bold;">then</span>
			:
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ERROR: &quot;</span> outside-to-inside scan has also failed <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;       &quot;</span> giving up on:                          <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;       &quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$line</span>&quot;</span>                                <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span>                                                  <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
			<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-A</span>  lsdc <span style="color: #660033;">--</span>  skip 000 000000000000 x x
			<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
&nbsp;
	<span style="color: #666666; font-style: italic;">#</span>
	<span style="color: #666666; font-style: italic;">#  Ignore . and ..</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$name</span> = . <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #007800;">$name</span> = .. <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-A</span>  lsdc <span style="color: #660033;">--</span>  skip 000 000000000000 x x
			<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">#</span>
	<span style="color: #666666; font-style: italic;">#  decode permissions  (the permission string is first word</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-A</span> perms <span style="color: #660033;">--</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span>print <span style="color: #660033;">--</span> <span style="color: #800000;">${permstring#?}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/./&amp; /g'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
	<span style="color: #007800;">extras</span>=<span style="color: #000000;">0</span>
	<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${perms[2]}</span> = S <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">extras</span>=extras+<span style="color: #000000;">4000</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; perms<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=- ; <span style="color: #7a0874; font-weight: bold;">&#125;</span>
	<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${perms[2]}</span> = s <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">extras</span>=extras+<span style="color: #000000;">4000</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; perms<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=x ; <span style="color: #7a0874; font-weight: bold;">&#125;</span>
	<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${perms[5]}</span> = S <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">extras</span>=extras+<span style="color: #000000;">2000</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; perms<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">5</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=- ; <span style="color: #7a0874; font-weight: bold;">&#125;</span>
	<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${perms[5]}</span> = s <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">extras</span>=extras+<span style="color: #000000;">2000</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; perms<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">5</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=x ; <span style="color: #7a0874; font-weight: bold;">&#125;</span>
	<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${perms[8]}</span> = T <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">extras</span>=extras+<span style="color: #000000;">1000</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; perms<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">8</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=- ; <span style="color: #7a0874; font-weight: bold;">&#125;</span>
	<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${perms[8]}</span> = t <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">extras</span>=extras+<span style="color: #000000;">1000</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; perms<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">8</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=x ; <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
	<span style="color: #007800;">binary</span>=<span style="color: #000000;">2</span><span style="color: #666666; font-style: italic;">#$(print -- ${perms[@]} | sed 's/ //g;s/-/0/g;s/[^0]/1/g')</span>
	<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">octal</span>=binary<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
	<span style="color: #007800;">result</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$octal</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
	<span style="color: #007800;">result</span>=<span style="color: #800000;">${result#??}</span>
	<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">result</span>=result+extras<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">#</span>
	<span style="color: #666666; font-style: italic;"># Decode date and time and convert it to yyyymmddhhmm</span>
&nbsp;
	<span style="color: #007800;">nmonth</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>conv_month <span style="color: #007800;">$month</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$swing</span> = <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$nmonth</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$THISMONTH</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">year</span>=LASTYEAR<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">year</span>=THISYEAR<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #007800;">time1</span>=<span style="color: #800000;">${swing%???}</span>
		<span style="color: #007800;">time2</span>=<span style="color: #800000;">${swing#???}</span>
		<span style="color: #007800;"><span style="color: #000000; font-weight: bold;">time</span></span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${time1}</span><span style="color: #007800;">${time2}</span>&quot;</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #000000; font-weight: bold;">else</span>
                <span style="color: #007800;">year</span>=<span style="color: #007800;">$swing</span>
		<span style="color: #007800;"><span style="color: #000000; font-weight: bold;">time</span></span>=<span style="color: #ff0000;">&quot;0000&quot;</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">#</span>
	<span style="color: #666666; font-style: italic;">#  Output the final record</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-A</span> lsdc <span style="color: #660033;">--</span> <span style="color: #800000;">${char1}</span> <span style="color: #800000;">${result}</span> <span style="color: #800000;">${year}</span><span style="color: #800000;">${nmonth}</span><span style="color: #800000;">${day}</span><span style="color: #800000;">${time}</span> <span style="color: #800000;">${name}</span> <span style="color: #800000;">${link}</span>
	<span style="color: #7a0874; font-weight: bold;">return</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  Function to process a remote file</span>
<span style="color: #666666; font-style: italic;">#  We will not overwrite and existing file unless we in &quot;freshen&quot; mode.</span>
<span style="color: #666666; font-style: italic;">#  And unless we are in &quot;freshen&quot; mode, it is an error for a file to</span>
<span style="color: #666666; font-style: italic;">#  pre-exist.</span>
&nbsp;
process_remote_file<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #007800;">VMESS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${VMESS}</span> is a remote file that&quot;</span>
	<span style="color: #007800;">do_get</span>=<span style="color: #000000;">0</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$name</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #007800;">VMESS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${VMESS}</span> already exists&quot;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>OPT_FRESHEN<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #007800;">line2</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-ld</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$name</span>&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
			lsdcode <span style="color: #ff0000;">&quot;<span style="color: #007800;">$line2</span>&quot;</span> 
			<span style="color: #007800;">char12</span>=<span style="color: #800000;">${lsdc[0]}</span>
			<span style="color: #007800;">mode2</span>=<span style="color: #800000;">${lsdc[1]}</span>
			<span style="color: #007800;">datestamp2</span>=<span style="color: #800000;">${lsdc[2]}</span>
			<span style="color: #007800;">name2</span>=<span style="color: #800000;">${lsdc[3]}</span>
			<span style="color: #007800;">link2</span>=<span style="color: #800000;">${lsdc[4]}</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$datestamp</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$datestamp2</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
				<span style="color: #007800;">VMESS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${VMESS}</span> but is out-of-date and&quot;</span>
				<span style="color: #007800;">do_get</span>=<span style="color: #000000;">1</span>
			<span style="color: #000000; font-weight: bold;">else</span>
				<span style="color: #007800;">VMESS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${VMESS}</span> and is current&quot;</span>
			<span style="color: #000000; font-weight: bold;">fi</span>
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #007800;">VMESS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${VMESS}</span> and cannot be retrieved&quot;</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> WARNING: no get since <span style="color: #007800;">$name</span> exists <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${localpath}</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #007800;">do_get</span>=<span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>do_get<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
		print <span style="color: #660033;">-p</span> get <span style="color: #000000; font-weight: bold;">\&quot;</span><span style="color: #ff0000;">&quot;<span style="color: #007800;">$name</span>&quot;</span><span style="color: #000000; font-weight: bold;">\&quot;</span>
		waitfor <span style="color: #007800;">$name</span>
		<span style="color: #007800;">VMESS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${VMESS}</span> has been retrieved&quot;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>OPT_MODE<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #007800;">$mode</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$name</span>&quot;</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$OPT_VERBOSE</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$VMESS</span>&quot;</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">#  Function to process a remote directory</span>
<span style="color: #666666; font-style: italic;">#  To this function, a remote directory is just an object that</span>
<span style="color: #666666; font-style: italic;">#  may need to be duplicated in the current directory</span>
&nbsp;
process_remote_directory<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
&nbsp;
	<span style="color: #007800;">VMESS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${VMESS}</span> is a remote directory that&quot;</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>OPT_DIRECTORIES<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #000000; font-weight: bold;">if</span> exists <span style="color: #007800;">$name</span>  ; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-d</span> <span style="color: #007800;">$name</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
				<span style="color: #007800;">VMESS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${VMESS}</span> cannot be created due to pre-existing object&quot;</span>
				<span style="color: #7a0874; font-weight: bold;">echo</span> WARNING: no <span style="color: #c20cb9; font-weight: bold;">mkdir</span> since <span style="color: #007800;">$name</span> exists <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${localpath}</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
			<span style="color: #000000; font-weight: bold;">else</span>
				<span style="color: #007800;">VMESS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${VMESS}</span> already exists&quot;</span>
			<span style="color: #000000; font-weight: bold;">fi</span>
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$name</span>&quot;</span>
			<span style="color: #007800;">VMESS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${VMESS}</span> has been created locally&quot;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>OPT_MODE<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
				<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #007800;">$mode</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$name</span>&quot;</span>
			<span style="color: #000000; font-weight: bold;">fi</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #007800;">VMESS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${VMESS}</span> has been ignored&quot;</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$OPT_VERBOSE</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$VMESS</span>&quot;</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>OPT_RECURS<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$name</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$name</span>&quot;</span>
			print <span style="color: #660033;">-p</span> lcd <span style="color: #000000; font-weight: bold;">\&quot;</span><span style="color: #ff0000;">&quot;<span style="color: #007800;">$name</span>&quot;</span><span style="color: #000000; font-weight: bold;">\&quot;</span>
			<span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000;">4</span><span style="color: #000000; font-weight: bold;">&lt;&amp;</span>-
			obtain_and_process_remote_ls <span style="color: #ff0000;">&quot;<span style="color: #007800;">$name</span>&quot;</span>
			print <span style="color: #660033;">-p</span> <span style="color: #7a0874; font-weight: bold;">cd</span> ..
			print <span style="color: #660033;">-p</span> lcd ..
			<span style="color: #7a0874; font-weight: bold;">cd</span> ..
			<span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000;">4</span><span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #800000;">${DIR_FILE_NAME[LEV]}</span>
			<span style="color: #007800;">lineno</span>=<span style="color: #000000;">0</span>
			<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> lineno <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #800000;">${DIR_LINE_NUM[LEV]}</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> ; <span style="color: #000000; font-weight: bold;">do</span>
				<span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #660033;">-u4</span> junk
				<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">lineno</span>=lineno+<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">done</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  Function to process a remote symlink</span>
<span style="color: #666666; font-style: italic;">#  Note that we deal with th symlink only --  not</span>
<span style="color: #666666; font-style: italic;">#  the object (if any) that the link points to.</span>
&nbsp;
process_remote_symlink<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #007800;">VMESS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${VMESS}</span> is a remote symlink that&quot;</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>OPT_SYMLINKS<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #000000; font-weight: bold;">if</span> exists <span style="color: #ff0000;">&quot;<span style="color: #007800;">$name</span>&quot;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-L</span> <span style="color: #007800;">$name</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
				<span style="color: #007800;">VMESS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${VMESS}</span> cannot be created due to pre-existing object&quot;</span>
				<span style="color: #7a0874; font-weight: bold;">echo</span> WARNING: no symlink since <span style="color: #007800;">$name</span> exists <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${localpath}</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
			<span style="color: #000000; font-weight: bold;">else</span>
				<span style="color: #007800;">VMESS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${VMESS}</span> already exists&quot;</span>
			<span style="color: #000000; font-weight: bold;">fi</span>
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$link</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$name</span>&quot;</span>
			<span style="color: #007800;">VMESS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${VMESS}</span> has been duplicated locally&quot;</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #007800;">VMESS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${VMESS}</span> has been ignored&quot;</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$OPT_VERBOSE</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$VMESS</span>&quot;</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  If a remote object is not a file, directory, or</span>
<span style="color: #666666; font-style: italic;">#  symlink, we come here.  </span>
&nbsp;
process_remote_weirdo<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #007800;">VMESS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${VMESS}</span> is a remote unknown object that has been ignored&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  This function obtains an &quot;ls&quot; listing from the remote ftp system.  Then it </span>
<span style="color: #666666; font-style: italic;">#  scans the listing line by line to figure out what to do.  It will completely </span>
<span style="color: #666666; font-style: italic;">#  process the current directory.</span>
&nbsp;
obtain_and_process_remote_ls<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
&nbsp;
	<span style="color: #7a0874; font-weight: bold;">typeset</span> rdir tmpfile okfile   <span style="color: #666666; font-style: italic;">## local scope variables ##</span>
	<span style="color: #007800;">rdir</span>=$<span style="color: #000000;">1</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">#</span>
	<span style="color: #666666; font-style: italic;">#  Set up variables or modify them if we have recursed</span>
&nbsp;
	<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">LEV</span>=LEV+<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
	<span style="color: #007800;">tmpfile</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>HardFeed.tp.<span style="color: #007800;">$$</span>.<span style="color: #800000;">${LEV}</span>
	<span style="color: #007800;">okfile</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>HardFeed.ok.<span style="color: #007800;">$$</span>.<span style="color: #800000;">${LEV}</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>LEV == <span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #007800;">localpath</span>=<span style="color: #007800;">$STARTPATH</span>
		<span style="color: #007800;">remotepath</span>=<span style="color: #007800;">$rdir</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #007800;">localpath</span>=<span style="color: #800000;">${localpath}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$rdir</span>
		<span style="color: #007800;">remotepath</span>=<span style="color: #800000;">${remotepath}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$rdir</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">#</span>
	<span style="color: #666666; font-style: italic;">#  Get a copy of the remote dir output in a local file</span>
	<span style="color: #666666; font-style: italic;">#  called $tmpfile </span>
&nbsp;
	print <span style="color: #660033;">-p</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">\&quot;</span><span style="color: #ff0000;">&quot;<span style="color: #007800;">$rdir</span>&quot;</span><span style="color: #000000; font-weight: bold;">\&quot;</span>
	print <span style="color: #660033;">-p</span> <span style="color: #007800;">$OPT_DIRCMD</span> <span style="color: #007800;">$tmpfile</span>
	print <span style="color: #660033;">-p</span> <span style="color: #007800;">$OPT_DIRCMD</span> <span style="color: #007800;">$okfile</span>
	waitfor <span style="color: #007800;">$okfile</span>
	DIR_FILE_NAME<span style="color: #7a0874; font-weight: bold;">&#91;</span>LEV<span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #007800;">$tmpfile</span>
	DIR_LINE_NUM<span style="color: #7a0874; font-weight: bold;">&#91;</span>LEV<span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #000000;">0</span>
	<span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000;">4</span><span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #007800;">$tmpfile</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">#</span>
	<span style="color: #666666; font-style: italic;">#  process each line</span>
	<span style="color: #666666; font-style: italic;">#</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #660033;">-u4</span> line ; <span style="color: #000000; font-weight: bold;">do</span>
		<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>DIR_LINE_NUM<span style="color: #7a0874; font-weight: bold;">&#91;</span>LEV<span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #800000;">${DIR_LINE_NUM[LEV]}</span>+<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
		lsdcode <span style="color: #ff0000;">&quot;<span style="color: #007800;">$line</span>&quot;</span> 
		<span style="color: #007800;">char1</span>=<span style="color: #800000;">${lsdc[0]}</span>
		<span style="color: #007800;">mode</span>=<span style="color: #800000;">${lsdc[1]}</span>
		<span style="color: #007800;">datestamp</span>=<span style="color: #800000;">${lsdc[2]}</span>
		<span style="color: #007800;">name</span>=<span style="color: #800000;">${lsdc[3]}</span>
		<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">link</span></span>=<span style="color: #800000;">${lsdc[4]}</span>
		<span style="color: #007800;">VMESS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${remotepath}</span>/<span style="color: #007800;">${name}</span>&quot;</span>
		<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #007800;">$char1</span> <span style="color: #000000; font-weight: bold;">in</span>
		skip<span style="color: #7a0874; font-weight: bold;">&#41;</span>   <span style="color: #000000; font-weight: bold;">;;</span>
		-<span style="color: #7a0874; font-weight: bold;">&#41;</span>      process_remote_file
			<span style="color: #000000; font-weight: bold;">;;</span>
		d<span style="color: #7a0874; font-weight: bold;">&#41;</span>      process_remote_directory
			<span style="color: #000000; font-weight: bold;">;;</span>
		l<span style="color: #7a0874; font-weight: bold;">&#41;</span>      process_remote_symlink
			<span style="color: #000000; font-weight: bold;">;;</span>
		<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>      process_remote_weirdo
			<span style="color: #000000; font-weight: bold;">;;</span>
		<span style="color: #000000; font-weight: bold;">esac</span>
	<span style="color: #000000; font-weight: bold;">done</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  We may have recursed...so we must put everything back the way</span>
<span style="color: #666666; font-style: italic;">#  we found it</span>
&nbsp;
	<span style="color: #007800;">localpath</span>=<span style="color: #800000;">${localpath%$rdir}</span>
	<span style="color: #007800;">localpath</span>=<span style="color: #800000;">${localpath%/}</span>
	<span style="color: #007800;">remotepath</span>=<span style="color: #800000;">${remotepath%$rdir}</span>
	<span style="color: #007800;">remotepath</span>=<span style="color: #800000;">${remotepath%/}</span>
	<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #007800;">$tmpfile</span>
	<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #007800;">$okfile</span>
	<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">LEV</span>=LEV-<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
	<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  Main Program</span>
<span style="color: #666666; font-style: italic;">#</span>
&nbsp;
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">ftp</span> <span style="color: #660033;">-inv</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">3</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">|&amp;</span>
print <span style="color: #660033;">-p</span> open <span style="color: #007800;">$SYSTEM</span>
print <span style="color: #660033;">-p</span> user <span style="color: #007800;">$USER</span> <span style="color: #007800;">$PASSWORD</span>
print <span style="color: #660033;">-p</span> binary
&nbsp;
<span style="color: #007800;">i</span>=<span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>OPT_CMDS<span style="color: #000000; font-weight: bold;">&gt;</span>i<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> ; <span style="color: #000000; font-weight: bold;">do</span>
	print <span style="color: #660033;">-p</span> <span style="color: #800000;">${OPT_CMDS_LIST[i]}</span>
	<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">i</span>=i+<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
obtain_and_process_remote_ls <span style="color: #007800;">$DIRECTORY</span>
&nbsp;
print <span style="color: #660033;">-p</span> bye
<span style="color: #7a0874; font-weight: bold;">wait</span>
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></td></tr></table></div>

<p>You just need to copy all the script, save it to a file, upload it to your server and run it. But first you must install the ksh, in ubuntu you can just type :</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> ksh</pre></div></td></tr></table></div>

<p>Example of using it :</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>hardfeed <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #c20cb9; font-weight: bold;">ftp</span> server<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">&lt;</span>username<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">&lt;</span>directory<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></td></tr></table></div>

<ul>
<li>./hardfeed : the name of the script</li>
<li>ftp server : the ip or the domain of the ftp server</li>
<li>username : the username of the ftp</li>
<li>directory : directory in the ftp server where you want to get the files from</li>
</ul>
<p>Here the another options which I copied from the website :<br />
HardFeed ftpserver joeblow somedir<br />
This will connect to &#8220;ftpserver&#8221; and the user &#8220;joeblow&#8221;. It will cd to &#8220;somedir&#8221;. It will look at all of the files (and only the files) there. Each remote file that does not exist in the current directory will be copied to the current directory.</p>
<p>HardFeed -ds ftpserver joeblow somedir<br />
This will work as the above example did. Except now we try to create local copies of any symbolic links or directories that we found in &#8220;somedir&#8221;. Again, though, we will not overwrite any pre-existing object.</p>
<p>HardFeed -rds ftpserver joeblow somedir<br />
Now we will create copies of any remote directories and desend into them. This will copy an entire directory tree. (except that it continues to ignore special files, pipes, etc.)</p>
<p>HardFeed -rs ftpserver joeblow somedir<br />
This is similiar, except we only desend into pre-existing directories. You can use this to copy part of a directory structure. Just pre-create the few directories that you want to copy.</p>
<p>HardFeed -rdsm ftpserver joeblow somedir<br />
This will copy a directory tree, but this time it will try to duplicate the mode (permissions) on each remote object that is duplicated.</p>
<p>HardFeed -rdsf ftpserver joeblow somdir<br />
The -f is &#8220;freshen&#8221;. Again it copies a directory tree. But if we have a local file and a remote file, the timestamps are compared. The remote file will overwrite the the local file if the remote file was newer.</p>
<p><a href="http://blog.rudylee.com/2010/06/08/copying-files-between-2-unix-servers/">Copying files between 2 unix servers</a> is a post from: <a href="http://blog.rudylee.com">SHARE Lifetime Experience</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rudylee.com/2010/06/08/copying-files-between-2-unix-servers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up NFS di Ubuntu</title>
		<link>http://blog.rudylee.com/2010/06/07/setting-up-nfs-di-ubuntu/</link>
		<comments>http://blog.rudylee.com/2010/06/07/setting-up-nfs-di-ubuntu/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 06:41:49 +0000</pubDate>
		<dc:creator>Rudy</dc:creator>
				<category><![CDATA[Unix dan Linux]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[nfs]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.rudylee.com/?p=485</guid>
		<description><![CDATA[NFS ( Network File Sharing ) adalah salah satu fitur di linux yang memungkinkan kita untuk men-share folder dan me-mountingnya ke server lain. Jadi misalnya gwa punya server A dengan folder /var/www/uploads dan gwa pengen folder itu bisa diakses dan dari server B.
Jadi solusinya adalah Server A gwa jadikan NFS Server dan Server B menjadi [...]<p><a href="http://blog.rudylee.com/2010/06/07/setting-up-nfs-di-ubuntu/">Setting up NFS di Ubuntu</a> is a post from: <a href="http://blog.rudylee.com">SHARE Lifetime Experience</a></p>
]]></description>
			<content:encoded><![CDATA[<p>NFS ( Network File Sharing ) adalah salah satu fitur di linux yang memungkinkan kita untuk men-share folder dan me-mountingnya ke server lain. Jadi misalnya gwa punya server A dengan folder /var/www/uploads dan gwa pengen folder itu bisa diakses dan dari server B.</p>
<p>Jadi solusinya adalah Server A gwa jadikan NFS Server dan Server B menjadi NFS Client. Dalam kasus ini gwa menggunakan Ubuntu ( karena gwa lagi buru-buru ). Untuk menginstall NFS Server cukup ketik :</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> nfs-kernel-server</pre></div></td></tr></table></div>

<p>Setelah itu tinggal setting folder yang mau dishare. Untuk settingannya terletak di folder /etc/exports, jadi sekarang kita edit dengan command :</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>exports</pre></div></td></tr></table></div>

<p>Kira-kira begini isinya :</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;"># /etc/exports: the access control list for filesystems which may be exported</span>
<span style="color: #adadad; font-style: italic;">#               to NFS clients.  See exports(5).</span>
<span style="color: #adadad; font-style: italic;">#</span>
<span style="color: #adadad; font-style: italic;"># Example for NFSv2 and NFSv3:</span>
<span style="color: #adadad; font-style: italic;"># /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)</span>
<span style="color: #adadad; font-style: italic;">#</span>
<span style="color: #adadad; font-style: italic;"># Example for NFSv4:</span>
<span style="color: #adadad; font-style: italic;"># /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)</span>
<span style="color: #adadad; font-style: italic;"># /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)</span>
<span style="color: #adadad; font-style: italic;">#</span>
&nbsp;
/var/www/uploads 202.58.181.0/<span style="color: #ff0000;">24</span>(rw,no_root_squash,async)</pre></div></td></tr></table></div>

<p>Penjelasannya kira-kira begini : </p>
<ul>
<li>/var/www/uploads = folder di server yang mau dishare </li>
<li>202.58.181.0/24 = ip yang diallow untuk melakukan nfs</li>
<li>(rw,no_root_squash,async) = rulenya ( ini rulenya untuk allow semuanya )</li>
</ul>
<p>Sekarang anda tinggal restart nfsnya dengan command :</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>nfs restart</pre></div></td></tr></table></div>

<p>Trus login ke dalam server yang pengen dimounting NFS nya dan ketik :</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">&lt;</span>ip nfs server<span style="color: #000000; font-weight: bold;">&gt;</span>:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>uploads <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>temp</pre></div></td></tr></table></div>

<p>Penjelasannya kira-kira begini :</p>
<ul>
<li>mount <ip nfs server> : ini diisi dengan ip nfs server / domain</li>
<li>/var/www/uploads : ini folder yang mau dishare di nfs server</li>
<li>/var/www/temp : ini tempat folder yang dimounting di client</li>
</ul>
<p><a href="http://blog.rudylee.com/2010/06/07/setting-up-nfs-di-ubuntu/">Setting up NFS di Ubuntu</a> is a post from: <a href="http://blog.rudylee.com">SHARE Lifetime Experience</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rudylee.com/2010/06/07/setting-up-nfs-di-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upload file in CakePHP using Media Plugin</title>
		<link>http://blog.rudylee.com/2010/06/03/upload-file-in-cakephp-using-media-plugin/</link>
		<comments>http://blog.rudylee.com/2010/06/03/upload-file-in-cakephp-using-media-plugin/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 10:42:02 +0000</pubDate>
		<dc:creator>Rudy</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[cake]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[upload]]></category>

		<guid isPermaLink="false">http://blog.rudylee.com/?p=478</guid>
		<description><![CDATA[There are many solutions to handle file upload in PHP. The common solution is to check the type of the file, size, check if the file name already exists or not, and the last is moving the file using move_uploaded_file(). But your task doesn&#8217;t end when the files are in your server, you still need [...]<p><a href="http://blog.rudylee.com/2010/06/03/upload-file-in-cakephp-using-media-plugin/">Upload file in CakePHP using Media Plugin</a> is a post from: <a href="http://blog.rudylee.com">SHARE Lifetime Experience</a></p>
]]></description>
			<content:encoded><![CDATA[<p>There are many solutions to handle file upload in PHP. The common solution is to check the type of the file, size, check if the file name already exists or not, and the last is moving the file using move_uploaded_file(). But your task doesn&#8217;t end when the files are in your server, you still need to write a function to delete the files, manipulate it if needed and so on.</p>
<p>I already tried several ways to handle upload file in CakePHP, from writing a private action in the app_controller and the last I write a component. </p>
<p>I can upload file, delete file, check the file type using my Upload Component, but I realize that there are many things missing in my component. </p>
<p>In searching for inspiration, I found CakePHP do have serveral plugins to handle File Upload and the features are beyond my component.</p>
<p>One of the plugin is <a href="http://github.com/davidpersson/media">Media Plugin</a> by Davidpersson.</p>
<p>Using the plugin is quite easy, but the wiki and the CakeFest slide is not updated with the new configuration ( I am using v1.3alpha ), so you need to jumped in to the core and trying to understand the new configuration.</p>
<p>Basically the plugin consist of several behaviours :</p>
<ul>
<li>Transfer</li>
<li>Polymorphic</li>
<li>Meta</li>
<li>Generator</li>
<li>Coupler</li>
</ul>
<p>But in this post I will just cover the Transfer,Coupler and Meta behaviour because I only understand these behaviours. So lets go to the implementation part, here is my CakePHP and Media Plugin version :</p>
<ol>
<li>CakePHP 1.3.0</li>
<li>Media Plugin 1.3 alpha</li>
</ol>
<p>First you must create a table that has a &#8216;file&#8217; field in it. Remember, the field must be named &#8216;file&#8217; or the plugin won&#8217;t working. Here is the example with my application :</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="apache" style="font-family:monospace;">CREATE TABLE IF NOT EXISTS `photos` (
  `id` int(<span style="color: #ff0000;">11</span>) NOT NULL AUTO_INCREMENT,
  `title` varchar(<span style="color: #ff0000;">255</span>) NOT NULL,
  `file` varchar(<span style="color: #ff0000;">255</span>) NOT NULL,
  `dirname` varchar(<span style="color: #ff0000;">255</span>) NOT NULL,
  `basename` varchar(<span style="color: #ff0000;">255</span>) NOT NULL,
  `checksum` varchar(<span style="color: #ff0000;">255</span>) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=<span style="color: #ff0000;">13</span> ;</pre></div></td></tr></table></div>

<p>The field that will be used by the plugin are file, dirname, basename, and checksum. But the three last fields is optional, so you can have it in your table or not (if you are using Coupler, and Meta behaviour you MUST add the there fields ). Next, bake the application ( I was using &#8216;cake bake&#8217; command ).</p>
<p>After that grab the Media Plugin from the github and put it in the plugins folder of your application. Next you will need to include the plugin to your application, open your bootstrap.php / core.php and add this line in it :</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require</span> APP <span style="color: #339933;">.</span> <span style="color: #0000ff;">'plugins/media/config/core.php'</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div>

<p>Then create the folder that will be used for storing the files. Go to your application folder in terminal and type this command ( ex: /var/www/sample ) :</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="php" style="font-family:monospace;">cake media init</pre></div></td></tr></table></div>

<p>The command will ask whether you want to create the directories or not, this is the print out of my terminal :</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="apache" style="font-family:monospace;">rudy@rudy-laptop:~/www/dummy$ cake media init
---------------------------------------------------------------
Media Shell
---------------------------------------------------------------
Do you want to create missing media directories now?
[n] &amp;gt; y
/dummy/webroot/media/                              [OK  ]
/dummy/webroot/media/static/                       [OK  ]
/dummy/webroot/media/static/aud                    [OK  ]
/dummy/webroot/media/static/css                    [OK  ]
/dummy/webroot/media/static/doc                    [OK  ]
/dummy/webroot/media/static/gen                    [OK  ]
/dummy/webroot/media/static/ico                    [OK  ]
/dummy/webroot/media/static/img                    [OK  ]
/dummy/webroot/media/static/js                     [OK  ]
/dummy/webroot/media/static/txt                    [OK  ]
/dummy/webroot/media/static/vid                    [OK  ]
/dummy/webroot/media/transfer/                     [OK  ]
/dummy/webroot/media/transfer/aud                  [OK  ]
/dummy/webroot/media/transfer/css                  [OK  ]
/dummy/webroot/media/transfer/doc                  [OK  ]
/dummy/webroot/media/transfer/gen                  [OK  ]
/dummy/webroot/media/transfer/ico                  [OK  ]
/dummy/webroot/media/transfer/img                  [OK  ]
/dummy/webroot/media/transfer/js                   [OK  ]
/dummy/webroot/media/transfer/txt                  [OK  ]
/dummy/webroot/media/transfer/vid                  [OK  ]
/dummy/webroot/media/filter/                       [OK  ]
&nbsp;
/dummy/webroot/media/transfer/.htaccess is not in your webroot.
Remember to set the correct permissions <span style="color: #0000ff;">on</span> transfer and filter <span style="color: #00007f;">directory</span>.</pre></div></td></tr></table></div>

<p>Change the permission of the folder so that the webserver can write in it :</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="apache" style="font-family:monospace;">chown -R www-data webroot/media</pre></div></td></tr></table></div>

<p>Configure the &#8216;Photo&#8217; model like this :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Photo <span style="color: #000000; font-weight: bold;">extends</span> AppModel <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Photo'</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$displayField</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'title'</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$actsAs</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Media.Transfer'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Media.Coupler'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Media.Meta'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$validate</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'file'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'mimeType'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'rule'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'checkMimeType'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'image/jpeg'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'image/png'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'size'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'rule'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'checkSize'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'5M'</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>As you can see I adding 3 behaviors ( Transfer, Coupler and Meta ). The transfer behavior is used for uploading,moving and validating the file, the coupler is for deleting the file ( it will automatically delete the file if you delete a record and also it will automatically add the value in dirname and basename ), and the meta for adding the meta description to the table ( checksum ).</p>
<p>Edit the add.ctp and adding the &#8216;type&#8217; => &#8216;file&#8217; in the $this->Form->create and the $this->Form->input(&#8216;file&#8217;) so the form can handle file upload. In the controller you don&#8217;t need to change anything because the behavior automatically handle the validation, the path and moving the file. this is my controller :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> PhotosController <span style="color: #000000; font-weight: bold;">extends</span> AppController <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Photos'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Photo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">recursive</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'photos'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">paginate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> view<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFlash</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Invalid %s'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'photo'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'action'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'index'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'photo'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Photo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> add<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Photo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Photo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">saveAll</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFlash</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'The %s has been saved'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'photo'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'action'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'index'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFlash</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'The %s could not be saved. Please, try again.'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'photo'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> edit<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$id</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFlash</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Invalid %s'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'photo'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'action'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'index'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Photo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFlash</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'The %s has been saved'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'photo'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'action'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'index'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFlash</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'The %s could not be saved. Please, try again.'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'photo'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Photo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> delete<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFlash</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Invalid id for %s'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'photo'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'action'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'index'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Photo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">delete</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFlash</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'%s deleted'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Photo'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'action'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'index'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFlash</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'%s was not deleted'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Photo'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'action'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'index'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>and this is my add view :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Photo'</span><span style="color: #339933;">,</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;?php</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'file'</span><span style="color: #339933;">,</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">end</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Submit'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/div&gt;</pre></td></tr></table></div>

<p>Now you are ready to uploading files, deleting files, and validate them in the model ( for validation you can see the wiki in the github for complete validation ). That&#8217;s all <img src='http://blog.rudylee.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><a href="http://blog.rudylee.com/2010/06/03/upload-file-in-cakephp-using-media-plugin/">Upload file in CakePHP using Media Plugin</a> is a post from: <a href="http://blog.rudylee.com">SHARE Lifetime Experience</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rudylee.com/2010/06/03/upload-file-in-cakephp-using-media-plugin/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
