需要 Shell 脚本从 ftp 链接下载文件吗?

发布于 2024-11-27 18:22:38 字数 660 浏览 4 评论 0原文

我需要获取这个文件 ftp://1034733:[电子邮件受保护]/idx_fl_ftp_down/idx_ftmyersbeach_dn/ftmyersbeach_data.zip 到我网站的服务器。这似乎是一个足够简单的任务......但是,我目前找不到解决方案。 PHP 似乎无法完成这项工作。 Wget 是我的下一个想法,但是,godaddy 安装的 wget 给了我一个“连接被拒绝”的问题(尽管 wget 在我的电脑上适用 - mac os x 10.6)。我现在认为这与 Godaddy 方面的事情有关,但我坚持我所拥有的。我的目标是编写一个通过 cron 作业执行的脚本(我需要每天下载这个文件)。请有人帮忙!我已经快要把头发从头上扯下来了!我过去两周都在做这个! 另外,我尝试通过 shell 和 wget 使用curl。两者都失败了。不幸的是我只能访问这个链接,我没有 idx.living.net 的 ftp 登录

I need to get this file
ftp://1034733:[email protected]/idx_fl_ftp_down/idx_ftmyersbeach_dn/ftmyersbeach_data.zip
to my site's server. THis seems like an easy enough task... but, I cannot find a solution at this point. PHP doesn't seem to be capable of getting the job done. Wget was my next thought, however, godaddy's installation of wget gives me a 'connection refused' problem (although it wget works for this on my computer - mac os x 10.6). I'm now thinking it has to do with godaddy's side of things, but I am stuck with what I have. My goal here is to write a script that will execute through a cron job (i need to download this file every day). Someone please help! I am to the point of ripping my hair out of my head! I've spent the last two weeks on this!
Also, I've tried using curl through the shell and wget. both have failed. Unfortunately I only have access to this link, I do not have an ftp login for idx.living.net

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青春有你 2024-12-04 18:22:38
#!/bin/sh

# ftpget - given an ftp: style URL, unwrap it, and try to obtain the file using ftp.

if [ $# -ne 2 ] && [ $# -ne 3 ]; then
  echo "Usage: $0 ftp://... username [password]" >&2
  exit 1
fi

# Typical URL: ftp://ftp.ncftp.com/2.7.1/ncftpd-2.7.1.tar.gz

if [ "$(echo $1 | cut -c1-6)" != "ftp://" ] ; then
  echo "$0: Malformed url. I need it to start with ftp://" >&2;
  exit 1
fi

server="$(echo $1 | cut -d/ -f3)"
filename="/$(echo $1 | cut -d/ -f4-)"
basefile="$(basename $filename)"
username="$(echo $2)"
password=""
if [ $# -eq 3 ] ; then
  password="$(echo $3)"
fi

#rm $basefile
echo ${0}: Downloading $basefile from server $server

ftp -n << EOF
open $server
user $username $password
bin
get $filename $basefile
quit
EOF

if [ $? -eq 0 ] ; then
  #chmod +x $basefile
  ls -l $basefile
fi

exit 0
#!/bin/sh

# ftpget - given an ftp: style URL, unwrap it, and try to obtain the file using ftp.

if [ $# -ne 2 ] && [ $# -ne 3 ]; then
  echo "Usage: $0 ftp://... username [password]" >&2
  exit 1
fi

# Typical URL: ftp://ftp.ncftp.com/2.7.1/ncftpd-2.7.1.tar.gz

if [ "$(echo $1 | cut -c1-6)" != "ftp://" ] ; then
  echo "$0: Malformed url. I need it to start with ftp://" >&2;
  exit 1
fi

server="$(echo $1 | cut -d/ -f3)"
filename="/$(echo $1 | cut -d/ -f4-)"
basefile="$(basename $filename)"
username="$(echo $2)"
password=""
if [ $# -eq 3 ] ; then
  password="$(echo $3)"
fi

#rm $basefile
echo ${0}: Downloading $basefile from server $server

ftp -n << EOF
open $server
user $username $password
bin
get $filename $basefile
quit
EOF

if [ $? -eq 0 ] ; then
  #chmod +x $basefile
  ls -l $basefile
fi

exit 0
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文