Automate ftp upload to ip

南楼画角 提交于 2019-12-10 11:55:10

问题


Is there a way to automate an upload of files from my local dekstop to an external ip address?

Maybe I can write a program in Java/C# that transfers my files from my local desktop to an external Ip and schedule that program every day for exemple??

Is this possible?

Thx


回答1:


Since you don't specify your OS, am going to assume a Standard OS (*nix), so you could proceed like this:

Create a Bash script (say myuploads.sh), and in it, you'll automate the uploading of the files of interest to the remote machine. Something like this:

#!/bin/bash

HOST='1.2.5.7'
USER='us3r'
PASSWD='p4ssword'
FILE_TO_UPLOAD='/path/to/some_file.some'
WHERE_TO_UPLOAD='/remote/path'

ftp -i -n $HOST <<Arul
user ${USER} ${PASSWD}

binary
cd $(WHERE_TO_UPLOAD)
put $(WHERE_TO_UPLOAD)

quit

U can then use a standard cron (job scheduler) to schedule when to periodically upload that file, using say a cron entry like this:

@daily /path/to/script/myuploads.sh >/dev/null

That runs the script once every day at midnight




回答2:


The magic keyword is crontab.

  • http://linuxwiki.de/crontab



回答3:


You mention C#, so for the windows system, place the ftp commands in a file:

user 
<your name>
<your password>
cd pub
bin
mput *
quit

and schedule a job to run ftp -n -s:cmd.file 127.0.0.1



来源:https://stackoverflow.com/questions/11028480/automate-ftp-upload-to-ip

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!