<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Delete files from FTP in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884017#M935348</link>
    <description>Clay,&lt;BR /&gt;&lt;BR /&gt;No problem.  I was a little miffed when I first read it but I quickly got over it.  It was late and I was tired.  No offense taken.  Besides, you were right.  :)&lt;BR /&gt;&lt;BR /&gt;I don't mind people being smug when they really, really know what they are doing!  Please feel free to keep banging my hard head with good solutions.  The owner's manual that came with me states, "Repeated percussive maintenance to the cranial region eventually yields positive results."  ;)&lt;BR /&gt;&lt;BR /&gt;the still humble JP&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 17 Jan 2003 16:14:18 GMT</pubDate>
    <dc:creator>John Poff</dc:creator>
    <dc:date>2003-01-17T16:14:18Z</dc:date>
    <item>
      <title>Delete files from FTP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884010#M935341</link>
      <description>how delete the files on the FTP server ,&lt;BR /&gt;only if they are 15 days old ?&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt; echo "open $SERVER&lt;BR /&gt; user $USER $PASS&lt;BR /&gt; ascii&lt;BR /&gt; cd temp&lt;BR /&gt;-- delete  15 days old files ?&lt;BR /&gt; close"&lt;BR /&gt; } | ftp -i -n&lt;BR /&gt;&lt;BR /&gt;thnx in advance</description>
      <pubDate>Thu, 16 Jan 2003 22:35:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884010#M935341</guid>
      <dc:creator>vas  bolpali</dc:creator>
      <dc:date>2003-01-16T22:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: Delete files from FTP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884011#M935342</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I don't think you have any commands in the ftp server to list the files older than 15 days.  What you might get away with is something like this:&lt;BR /&gt;&lt;BR /&gt;open your connection and login&lt;BR /&gt;get a list of all the files&lt;BR /&gt;closing the connection&lt;BR /&gt;&lt;BR /&gt;If you redirect the output from this session to a file, you can write a script to figure out which files you want to delete and build a script to drive a second ftp session to login and delete the files.&lt;BR /&gt;&lt;BR /&gt;open connection and login&lt;BR /&gt;delete file&lt;BR /&gt;delete file&lt;BR /&gt;...&lt;BR /&gt;close&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I don't know what your situation is, but it probably would be much easier to delete the old files from the ftp server end.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Thu, 16 Jan 2003 22:47:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884011#M935342</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2003-01-16T22:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: Delete files from FTP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884012#M935343</link>
      <description>Hi,&lt;BR /&gt;You can not search for files older from ftp prompt. The best and easiest way would be to search and delete them from the ftp server side by putting some scripts and then triger the ftp from there instead from your end.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Rajeev</description>
      <pubDate>Fri, 17 Jan 2003 02:12:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884012#M935343</guid>
      <dc:creator>Rajeev  Shukla</dc:creator>
      <dc:date>2003-01-17T02:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: Delete files from FTP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884013#M935344</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Just as an object lesson to you guys that say it can't be done and as another opportunity to bang you over the head with "USE PERL FOR FTP", I whipped this example up in under 5 minutes. As is, it logs in, cd's to /tmp, does an ls, and gets the last modification times of each file. If any are older than 15 days, it deletes them.&lt;BR /&gt;&lt;BR /&gt;You will need to install the Net::FTP module from &lt;A href="http://www.perl.org/CPAN." target="_blank"&gt;www.perl.org/CPAN.&lt;/A&gt; You will also need to uncomment the actual delete call when you get close.&lt;BR /&gt;&lt;BR /&gt;Some suggested improvement:&lt;BR /&gt;1) Do a dir and only look for regular files but that is left as an exercise for the reader. 2) Add a bit of error checking - hard with scripts but duck soup with Net::FTP.&lt;BR /&gt;&lt;BR /&gt;That's all you get for 5 minutes. &lt;BR /&gt;&lt;BR /&gt;Smug regards,&lt;BR /&gt;Clay&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Jan 2003 02:21:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884013#M935344</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-01-17T02:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Delete files from FTP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884014#M935345</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You can do it with quite a bit of scripting if you really want to do.&lt;BR /&gt;&lt;BR /&gt;You may have to do it in multiple iterations&lt;BR /&gt;&lt;BR /&gt;Your first part will get the details. This is a high level script.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin&lt;BR /&gt;&lt;BR /&gt;{ &lt;BR /&gt;echo "open $SERVER &lt;BR /&gt;user $USER $PASS &lt;BR /&gt;ascii &lt;BR /&gt;cd temp &lt;BR /&gt;dir &lt;BR /&gt;close" &lt;BR /&gt;} | ftp -i -n &amp;gt; ftp.log &lt;BR /&gt;&lt;BR /&gt;tough_part()&lt;BR /&gt;{&lt;BR /&gt;This ftp.log contains output with files and their date stamps. Here is the most difficult part. Find out the files in the output that are more than 15days (how?). Try caljd.sh floating around in these forums. Assign them to a variable say FILES. &lt;BR /&gt;Use ftp again to delete them using "mdelete"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;{ &lt;BR /&gt;echo "open $SERVER &lt;BR /&gt;user $USER $PASS &lt;BR /&gt;ascii &lt;BR /&gt;cd temp &lt;BR /&gt;mdelete $FILES &lt;BR /&gt;close" &lt;BR /&gt;} | ftp -i -n &lt;BR /&gt;&lt;BR /&gt;Since it is tedious, I would suggest you to run a script through cron on the ftp server to clean the files.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Fri, 17 Jan 2003 02:23:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884014#M935345</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2003-01-17T02:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: Delete files from FTP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884015#M935346</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I didn't say it couldn't be done.  My point was that it could be done with some scripting.  &lt;BR /&gt;&lt;BR /&gt;the humble JP&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Jan 2003 03:03:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884015#M935346</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2003-01-17T03:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: Delete files from FTP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884016#M935347</link>
      <description>Hi John:&lt;BR /&gt;&lt;BR /&gt;I trust that you know that was all tongue in cheek. This was simply an irrestible chance to illustrate what is at best tedious using shell, awk, grep, cut, ... becomes almost trivial when you choose the right club.&lt;BR /&gt;&lt;BR /&gt;Humble (more or less) regards, Clay&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Jan 2003 03:39:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884016#M935347</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-01-17T03:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: Delete files from FTP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884017#M935348</link>
      <description>Clay,&lt;BR /&gt;&lt;BR /&gt;No problem.  I was a little miffed when I first read it but I quickly got over it.  It was late and I was tired.  No offense taken.  Besides, you were right.  :)&lt;BR /&gt;&lt;BR /&gt;I don't mind people being smug when they really, really know what they are doing!  Please feel free to keep banging my hard head with good solutions.  The owner's manual that came with me states, "Repeated percussive maintenance to the cranial region eventually yields positive results."  ;)&lt;BR /&gt;&lt;BR /&gt;the still humble JP&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Jan 2003 16:14:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884017#M935348</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2003-01-17T16:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: Delete files from FTP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884018#M935349</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Try to this via a remote shell instead!&lt;BR /&gt;remsh &lt;REMOTE_HOST&gt; -l &lt;REMOTE_USER&gt; -n find /temp/ -mtime +15 -exec rm {} \;&lt;BR /&gt;&lt;BR /&gt;If your remote system isn't a remsh incompatible environment try via ftp by "literal" command.&lt;BR /&gt;&lt;BR /&gt;Rgds.&lt;/REMOTE_USER&gt;&lt;/REMOTE_HOST&gt;</description>
      <pubDate>Fri, 17 Jan 2003 17:01:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884018#M935349</guid>
      <dc:creator>Jose Mosquera</dc:creator>
      <dc:date>2003-01-17T17:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: Delete files from FTP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884019#M935350</link>
      <description>I had a few spare minutes today and I went back and added a quick improvement. The ls method was replaced with the dir method (essentially an ls -l command) so that we can determine if this is a regular file. (Directories, pipes, symbolic links are skipped). If the first character of the first field of the dir listing is a '-' then we know the file is a regular file. The filename is the last field of the ls -l line.&lt;BR /&gt;&lt;BR /&gt;Next we check to see if the file has been modified in the last 15 days. If not the file is deleted.&lt;BR /&gt;&lt;BR /&gt;With only a little more work, you could make this a recursive function that would descend directories and continue the process but that is left as an exercise.&lt;BR /&gt;&lt;BR /&gt;The power of this approach is that it could even be run from a Windows box without change. I never do any FTP stuff with Perl anymore; it's just too hard any other way especially if you care about minor little things like error checking.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Jan 2003 20:20:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/delete-files-from-ftp/m-p/2884019#M935350</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-01-17T20:20:54Z</dc:date>
    </item>
  </channel>
</rss>

