<?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: Script to move files in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685636#M932166</link>
    <description>Hello&lt;BR /&gt;I was looking at your issue and thinking that the problem would be that the file keeps growing and you dont have to &lt;BR /&gt;Here is what I am doing. &lt;BR /&gt;&lt;BR /&gt;1. testing the file size for file1 and giving it var filesize&lt;BR /&gt;2. sleeping for 5 secs to let the file grow.&lt;BR /&gt;3. testing the file size again and giving it var filesize1&lt;BR /&gt;4. going into a loop that will go testing on untill filesize1 is equal to filesize.&lt;BR /&gt;5. when the look is done and filesize1=filesize (meaning that the file has stopped growing) then it will perform an action. I did an echo .. you will do a mv. &lt;BR /&gt;&lt;BR /&gt;#/usr/bin/sh&lt;BR /&gt;ll file1 | awk '{print $5}' | read filesize&lt;BR /&gt;sleep 5&lt;BR /&gt;ll file1 | awk '{print $5}' | read filesize1&lt;BR /&gt;until [  $filesize -eq $filesize1 ]&lt;BR /&gt;do&lt;BR /&gt;ll file1 | awk '{print $5}' | read filesize&lt;BR /&gt;sleep 5&lt;BR /&gt;ll file1 | awk '{print $5}' | read filesize1&lt;BR /&gt;echo "files are not the same"&lt;BR /&gt;done&lt;BR /&gt;echo " files  are the same "&lt;BR /&gt;#_end&lt;BR /&gt;&lt;BR /&gt;Richard</description>
    <pubDate>Tue, 19 Mar 2002 00:02:00 GMT</pubDate>
    <dc:creator>someone_4</dc:creator>
    <dc:date>2002-03-19T00:02:00Z</dc:date>
    <item>
      <title>Script to move files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685628#M932158</link>
      <description>I have a compiled application for which there is no source code.  I am writing a script to replace the application.  Speed is not a problem so a script should do fine.&lt;BR /&gt;&lt;BR /&gt;I have a separate application over which I have no control.  At random intervals it opens up an FTP session and drops a file into the IN directory.&lt;BR /&gt;&lt;BR /&gt;The process I am trying to replace does nothing more than look for files in the IN directory and move any files it finds from the IN directory to the OUT directory.  Any file which appears in the Out directory will be worked on by another process (which I have already replaced with a script).  The old process runs continually but my script will probably just run every 15 minutes or so.&lt;BR /&gt;&lt;BR /&gt;I was told that the reason the first process didn't just drop files into the OUT directory was because they were afraid that the OUT process would start to work on a partial file before the FTP was complete.  I don't know if this is true or not but it sounds reasonable.&lt;BR /&gt;&lt;BR /&gt;Given that this is the case how can I write a script that doesn't move a file from the IN directory until the FTP is complete?&lt;BR /&gt;&lt;BR /&gt;Obviously I can have the script look at netstat -a|grep ftp to make sure that there are no FTPs going on but is there a cleaner way or should I even worry about it?&lt;BR /&gt;&lt;BR /&gt;Ron</description>
      <pubDate>Mon, 18 Mar 2002 22:45:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685628#M932158</guid>
      <dc:creator>Ron Kinner</dc:creator>
      <dc:date>2002-03-18T22:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: Script to move files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685629#M932159</link>
      <description>Hi Ron,&lt;BR /&gt;&lt;BR /&gt;Your script is running every 15 minuts so you can check timestemp of files(in IN directory) and move all files whose timestamp is older then current time. Considering that network is good.&lt;BR /&gt;&lt;BR /&gt;for example you start your script at 1:15 then move all files whose time stamp is 1:12 or older.&lt;BR /&gt;&lt;BR /&gt;Your idea is not bad either. you can add that as one more level checking.&lt;BR /&gt;&lt;BR /&gt;Sachin</description>
      <pubDate>Mon, 18 Mar 2002 22:56:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685629#M932159</guid>
      <dc:creator>Sachin Patel</dc:creator>
      <dc:date>2002-03-18T22:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: Script to move files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685630#M932160</link>
      <description>Hi Ron,&lt;BR /&gt;&lt;BR /&gt;what we've always done in this situation is to create the file with a temp name and then once it's on the system, rename it.  So the NT process that dumps the file would name it file1.tmp and the last step of the process would rename it say file1.dat.  then you would only move the files ending with .dat  Hope this helps a little&lt;BR /&gt;&lt;BR /&gt;Jake</description>
      <pubDate>Mon, 18 Mar 2002 23:10:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685630#M932160</guid>
      <dc:creator>Jacob D Levin</dc:creator>
      <dc:date>2002-03-18T23:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Script to move files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685631#M932161</link>
      <description>You could also use fuser to see if there are any processes accessing the files.  If fuser shows nothing then you are OK.</description>
      <pubDate>Mon, 18 Mar 2002 23:10:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685631#M932161</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2002-03-18T23:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: Script to move files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685632#M932162</link>
      <description>Hi Ron:&lt;BR /&gt;&lt;BR /&gt;The missing piece of your problem is a small script to determine if the file has been modified. Try this small Perl script, 'fileage.pl':&lt;BR /&gt;&lt;BR /&gt;ls | while read FNAME&lt;BR /&gt;  do&lt;BR /&gt;     fileage.pl -m -s 600 ${FNAME}&lt;BR /&gt;     STAT=$?&lt;BR /&gt;     if [ ${STAT} -eq 1 ]&lt;BR /&gt;       then&lt;BR /&gt;         echo "File has been modified in the last 10 minutes"&lt;BR /&gt;       else&lt;BR /&gt;         echo "File has not been modified; safe to copy"&lt;BR /&gt;       fi&lt;BR /&gt;   done&lt;BR /&gt;&lt;BR /&gt;If you like, you can add a -v argument and a 0 or 1 is printed to stdout to indicate whether the file has been modified. Normally, fileage.pl does its work silently and the exit status is used to indicate whether the file has been changed.&lt;BR /&gt;&lt;BR /&gt;Fileage.pl -u will give full usage.&lt;BR /&gt;&lt;BR /&gt;Regards, Clay&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Mar 2002 23:15:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685632#M932162</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-03-18T23:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: Script to move files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685633#M932163</link>
      <description>The ftp process could certainly rename the file after the put process allowing you to check for only the named files.&lt;BR /&gt;This would be a safe bet on large file transfers that could run more than 15 min.&lt;BR /&gt;&lt;BR /&gt;just my .02.&lt;BR /&gt;&lt;BR /&gt;Best of luck.&lt;BR /&gt;dl</description>
      <pubDate>Mon, 18 Mar 2002 23:16:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685633#M932163</guid>
      <dc:creator>Dave La Mar</dc:creator>
      <dc:date>2002-03-18T23:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: Script to move files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685634#M932164</link>
      <description>Ron,&lt;BR /&gt;&lt;BR /&gt;Thinking along the lines of using netstat -a|grep ftp ... I would use lsof to do that kind of checking.&lt;BR /&gt;&lt;BR /&gt;###If the VAR1 variable is not empty then this means that ftp is still in progress&lt;BR /&gt;VAR1=`lsof | grep &lt;USERNAME of="" who="" is="" doing="" ftp=""&gt; | grep in.ftpd`&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;if [[ -n ${VAR1} ]]; then&lt;BR /&gt;print "FTP in progress, cannot move file"&lt;BR /&gt;else&lt;BR /&gt;print "NO FTP session in progress, safe to move file"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;If you know the username of who is doing the ftp then this logic will work.&lt;BR /&gt;&lt;BR /&gt;I haven't tested this on a HP machine.&lt;BR /&gt;&lt;BR /&gt;I also like Jacob's idea of renaming the file after an ftp is complete..&lt;BR /&gt;&lt;BR /&gt;HOpe this helps !&lt;BR /&gt;&lt;BR /&gt;-Shabu&lt;/USERNAME&gt;</description>
      <pubDate>Mon, 18 Mar 2002 23:46:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685634#M932164</guid>
      <dc:creator>SHABU KHAN</dc:creator>
      <dc:date>2002-03-18T23:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: Script to move files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685635#M932165</link>
      <description>Patrick gets the rabbit pelt and the full 10 points.  I like his solution best since it appears to be easiest for me to work with.  I just tested it and it works nicely and is much faster than my netstat -a|grep ftp idea.&lt;BR /&gt;&lt;BR /&gt;The 7's are for solutions that would have worked if I weren't so lazy.  (Don't have perl on this box and didn't really want to load it.  Ditto for lsof.  This is  a special purpose box and it very basic without any frills.)&lt;BR /&gt;&lt;BR /&gt;The 5's are for those who suggested changing the file name at the end of the FTP process.  Remember I have no control over the process which ftps to me.  I have to take what I get.&lt;BR /&gt;&lt;BR /&gt;Thanks to all who replied tho.  &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Ron</description>
      <pubDate>Mon, 18 Mar 2002 23:56:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685635#M932165</guid>
      <dc:creator>Ron Kinner</dc:creator>
      <dc:date>2002-03-18T23:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: Script to move files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685636#M932166</link>
      <description>Hello&lt;BR /&gt;I was looking at your issue and thinking that the problem would be that the file keeps growing and you dont have to &lt;BR /&gt;Here is what I am doing. &lt;BR /&gt;&lt;BR /&gt;1. testing the file size for file1 and giving it var filesize&lt;BR /&gt;2. sleeping for 5 secs to let the file grow.&lt;BR /&gt;3. testing the file size again and giving it var filesize1&lt;BR /&gt;4. going into a loop that will go testing on untill filesize1 is equal to filesize.&lt;BR /&gt;5. when the look is done and filesize1=filesize (meaning that the file has stopped growing) then it will perform an action. I did an echo .. you will do a mv. &lt;BR /&gt;&lt;BR /&gt;#/usr/bin/sh&lt;BR /&gt;ll file1 | awk '{print $5}' | read filesize&lt;BR /&gt;sleep 5&lt;BR /&gt;ll file1 | awk '{print $5}' | read filesize1&lt;BR /&gt;until [  $filesize -eq $filesize1 ]&lt;BR /&gt;do&lt;BR /&gt;ll file1 | awk '{print $5}' | read filesize&lt;BR /&gt;sleep 5&lt;BR /&gt;ll file1 | awk '{print $5}' | read filesize1&lt;BR /&gt;echo "files are not the same"&lt;BR /&gt;done&lt;BR /&gt;echo " files  are the same "&lt;BR /&gt;#_end&lt;BR /&gt;&lt;BR /&gt;Richard</description>
      <pubDate>Tue, 19 Mar 2002 00:02:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685636#M932166</guid>
      <dc:creator>someone_4</dc:creator>
      <dc:date>2002-03-19T00:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: Script to move files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685637#M932167</link>
      <description>&lt;BR /&gt;If you have lsof (&lt;A href="http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.61/)" target="_blank"&gt;http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.61/)&lt;/A&gt; and speed is not crucial, then you can check to see if each file is open by another process. If so, skip; If not, move it. Let's assume that the incoming and outgoing directories are in the ftp pub directory, then do this (as root):&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;cd ~ftp/pub&lt;BR /&gt;find incoming -type f |while read file junk&lt;BR /&gt;do&lt;BR /&gt;if ! lsof $file &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;then&lt;BR /&gt;mv $file outgoing&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;This works only if lsof returns 0 if the file is open, and 1 if not or if it does not have enough permission to check.&lt;BR /&gt;</description>
      <pubDate>Tue, 19 Mar 2002 00:08:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685637#M932167</guid>
      <dc:creator>Jordan Bean</dc:creator>
      <dc:date>2002-03-19T00:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: Script to move files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685638#M932168</link>
      <description>Enough guys,&lt;BR /&gt;&lt;BR /&gt;I like the fuser idea.  It's short and sweet.  I don't want to have to install stuff that's not there now and I'm not in a hurry.  I have 48 hours to get the file processed so if a file is still being FTP'd I'll skip it and get it next time which will probably be in 15 minutes.  The file are generally fairly short like under 10K so they don't take too long to transfer.&lt;BR /&gt;&lt;BR /&gt;Ron</description>
      <pubDate>Tue, 19 Mar 2002 02:22:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685638#M932168</guid>
      <dc:creator>Ron Kinner</dc:creator>
      <dc:date>2002-03-19T02:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: Script to move files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685639#M932169</link>
      <description>It's sounds like what you have in mind with checking for ftp would work fine.  You could also use fuser -fu on the files and see if there is any output.  Once you have checked for files in use, you can then copy the files over to the OUT directory.</description>
      <pubDate>Tue, 19 Mar 2002 20:06:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-move-files/m-p/2685639#M932169</guid>
      <dc:creator>CHRISTSHONDA CAMPBELL</dc:creator>
      <dc:date>2002-03-19T20:06:55Z</dc:date>
    </item>
  </channel>
</rss>

