#1
  1. No Profile Picture
    Closet coder
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Feb 2005
    Location
    Plantation, FL <---south florida
    Posts
    1,431
    Rep Power
    153

    Ftp and batch file question


    im gonna be writing a script that will seach a folder for a certain file extension and FTP these particular files to an AS/400 server automatically (ie an in house service will be running that runs this script every few minutes). these files are being created by another small console app. i only want to send the files when they are complete, and since this process of createing them is pretty damn quick i dont think there will be a problem... but there is always the chance that the ftp script will try to send the file at a moment when the file will be open and being created. so if anyone can answer this, will the ftp fail if a file is open and being written too at that moment that it tries to send it(which would be great, because then the script could pick it up on the next pass) or will it send a partial file (which is not great)?
  2. #2
  3. fork while true;
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2005
    Location
    England, UK
    Posts
    5,538
    Rep Power
    1051
    no, it will not fail.

    You should try copying it to another directory and then mv'ing it. you're guaranteed to be sorted via mv, since all it does it reroute an inode, and therefore doesn't actually move the file at all.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2006
    Location
    West Yorkshire, England
    Posts
    236
    Rep Power
    16
    Failure is a function of the operating system. LinuxPenguin is correct in that it won't fail on a linux/unix OS. On a Windows OS, then it depends upon the flags given then the file is create/opened by the creating process.

    I agree about the moving of the file. This will work for for both OSs.
  6. #4
  7. No Profile Picture
    Closet coder
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Feb 2005
    Location
    Plantation, FL <---south florida
    Posts
    1,431
    Rep Power
    153
    just to follow up, yea i went with moving the file first to a temp FTP directory and from there a little mfc app will push the files to the server. thanks for the info.

IMN logo majestic logo threadwatch logo seochat tools logo