LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   SFTP Mput help! (https://www.linuxquestions.org/questions/linux-newbie-8/sftp-mput-help-873343/)

Mackenzie 04-06-2011 09:16 AM

SFTP Mput help!
 
Hello everyone, I am new here at the forums, but I have a little Linux background from college getting Linux + certified. Although I am certified, I got that certification when Fedora Core 4 was out and now it's way beyond that... plus I haven't used Linux much since I got out of college. Anyways enough about me.. here's what I've got.

I work at a hospital. The hospital has an outter office that reads x-rays from the hospital. We have these on a server here at the hospital (in folders named after the day 04.06.11) and we are going to be uploading them to a corporate server so the outter office can see them. We are using SFTP for this. Currently I am working in Windows, but I am using the putty program inside of command prompt, which uses Linux based commands.

Right now whenever a new x-ray comes through a person from our hospital puts the file into an archive folder on the server. We then run Xcopy to copy over the new files. Here is my xcopy command
Quote:

xCopy /d /s /e /m /y SERVERNAME\mesa\archive\*.* d:\mesa\
This copies the files from the folder archive to the d:\mesa folder.

Now what I've got are 2 scripts I've wrote to connect to the SFTP site and switch to the directory needed and copy files over.

FTP1.BAT
Quote:

psftp -pw XXXXXX -l USERNAME@SERVER -P XXXX -b C:\Users\\ME\Desktop\ftp2.bat
FTP2.BAT
Quote:

open "USERNAME@SERVER" XXXX
cd To_CCS/scans/
mput C:\mesa\archive\*.pdf
Now what I am wanting to do is something like Xcopy, but with the ftp site.

Is there ANY way to get it to where the mput or put command looks for only new files that are not already on the server? What's going on now is whenever I run this, it will copy all the files over again whether they are already there or not.. waisting time and bandwidth. I thought about running a script to compare the archive folder and regular mesa folder to a text file then copy those files over, but I can't seem to figure this out either.. although that would be a Windows batch file to do that I'd hope someone here could help me. I'd greatly appreciate any help offered, as this will make my job a lot easier so I can just schedule a task to do this and I can do other things.

Thanks in advance!
-Mackenzie

chrism01 04-06-2011 08:53 PM

Sounds like a job for rsync http://linux.die.net/man/1/rsync, but I don't know how you'd talk to MS-Windows; you might need to install Cygwin (gives you a *nix cmd line/env inc tools) on the MS box.
Alternately why don't you create a txfr dir on your PC and download new files into that first, then copy them to Linux, then mv new files to archive dir (if I understand your description).

I'm sure someone else will coma long with a better idea soon ....


All times are GMT -5. The time now is 11:38 AM.