-1

I'm trying to upload a file from local to FTP every 10 minutes .I just have the FTP login information and I need the process to be automatically done every time the user log to windows .How could I do so ?

Thanks

2
  • Please note that Super User is not a script writing service. If you tell us what you have tried so far (including any scripts you are using) and where you are stuck then we can try to help with specific problems. You should also read How do I ask a good question?.
    – DavidPostill
    Jul 25, 2016 at 12:40
  • Let me know if you found my answer helpful when you get a chance? Jul 28, 2016 at 0:56

3 Answers 3

1

Give this a shot with the below commands which will work as a batch script. Just put your variable values in accordingly where needed for the FTP server URL or IP address, the username and password, the file name, and the ftptmpfile.

I too would suggest using Windows Task Scheduler to schedule this script to run at the time intervals you need once you confirm it works as expected once you get it confirmed to work.

I assume you're already familiar with most of this but let me know if you have any problems or questions.

FTP Batch Script Example

(NOTE: If needed just change the ECHO mput filename.file "uploaddir\filename.file">> %ftptmpfile% to be ECHO put filename.file "uploaddir\filename.file">> %ftptmpfile% instead)

ECHO open ftp.ftpserver.com>> %ftptmpfile%
ECHO ftpusername>> %ftptmpfile%
ECHO ftppassword>> %ftptmpfile%
ECHO prompt>> %ftptmpfile%
ECHO binary>> %ftptmpfile%
ECHO put filename.file "uploaddir\filename.file">> %ftptmpfile%
ECHO dir>> %ftptmpfile%
ECHO bye>> %ftptmpfile%
ftp -s:%ftptmpfile%
IF EXIST "%ftptmpfile%" DEL /Q /F "%ftptmpfile%"

Further Resources

1
  • The ftp command line needs the -i switch if multiple files are being transferred. Oh wait, there is only one file. No need to use mput for one file. Use put.
    – lit
    Jul 27, 2016 at 23:21
0

Create a batch or VB script that does exactly what you want. Include it to keep running endlessly and let it upload every 10 minutes.

Then, you can create a scheduled task to execute it at logon.

I do not see a good reason why you would want to do such a thing, though ... And why start at logon if it needs to run every ten minutes? You can just schedule it to run every ten minutes.

1
  • thanks, But What's the commands to write in batch file ?
    – j edgar
    Jul 25, 2016 at 12:18
-1

@PIMP_JUICE_IT has the right answer. Do not select this as the answer. This is only reformatting of PIMP_JUICE_IT's answer. I find it clearer and easier to write by putting the temp file first. Then, the remainder of the line looks like the FTP script.

Quoting is safer and required if the TEMP variable has a space character in it.

Also, using the RANDOM variable in the temp file name gives it a better chance of being unique, but is not guaranteed. There are ways to do that, but beyond the scope of this note. Deleting any existing temp file ensures that the code is not appending to an existing file which would be bad for this script. However, if another program is actually using that temp file, it would probably have deleterious effects on the other program.

SET "ftptmpfile=%TEMP%\app_ftp_%RANDOM%.tmp"
IF EXIST "%ftptmpfile%" (DEL /Q /F "%ftptmpfile%")

ECHO>>"%ftptmpfile%" open ftp.ftpserver.com
ECHO>>"%ftptmpfile%" ftpusername
ECHO>>"%ftptmpfile%" ftppassword
ECHO>>"%ftptmpfile%" prompt
ECHO>>"%ftptmpfile%" binary
ECHO>>"%ftptmpfile%" put filename.file "uploaddir\filename.file"
ECHO>>"%ftptmpfile%" dir
ECHO>>"%ftptmpfile%" bye

ftp -s:"%ftptmpfile%"
IF EXIST "%ftptmpfile%" DEL /Q /F "%ftptmpfile%"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .