Bash FTP/WPUT,有简单的工作解决方案吗?

Bash FTP/WPUT,有简单的工作解决方案吗?,bash,ftp,automation,ip-address,Bash,Ftp,Automation,Ip Address,抱歉,我知道这是一个涵盖面很广的问题,但我似乎找不到任何简单的解决方案 试图解决一个问题,我希望有人能帮忙 我正在创建一个脚本,我能想到的解决这个特殊问题的唯一方法是通过FTP将文件传输到远程web服务器 .sh脚本,我最初尝试了FTP,但似乎在使用密码时出现了问题,我尝试了一些解决方法,但没有成功 然后我尝试了wput,但似乎也失败了 #!/bin/sh wput -v file.php ftp://usr:pass@host.co.uk/docroot/ bash wput.sh wpu

抱歉,我知道这是一个涵盖面很广的问题,但我似乎找不到任何简单的解决方案

试图解决一个问题,我希望有人能帮忙

我正在创建一个脚本,我能想到的解决这个特殊问题的唯一方法是通过FTP将文件传输到远程web服务器

.sh脚本,我最初尝试了FTP,但似乎在使用密码时出现了问题,我尝试了一些解决方法,但没有成功

然后我尝试了wput,但似乎也失败了

#!/bin/sh
wput -v file.php ftp://usr:pass@host.co.uk/docroot/

 bash wput.sh
wput.sh: line 2: $'\r': command not found
--12:20:58-- `/file.php'
    => ftp://user:xxxxx@host.co.uk/docroot/
Connecting to host.co.uk:21... connected!
Logging in as user ... Logged in!
==> CWD docroot
==> TYPE I ... done.
 ... failed.
==> SYST ... done (UNIX Type: L8).
==> PASV ... done.
==> TYPE A ... done.
==> LIST ... done.
==> TYPE I ... done.
==> PASV ... done.
' not understood) Skipping this file
FINISHED --12:20:59--
Transmission of 1 file failed.
wput.sh: line 4: $'\r': command not found
wput.sh: line 5: $'\r': command not found
有人能告诉我哪里出了问题吗。这可能是文件权限问题还是什么

我所需要的是一个最简单的解决方案,可以以最简单的方式将文件从我的计算机自动传输到某个web空间


谢谢

尝试使用
ncftpput

ncftpput
帮助菜单中显示的示例:

  ncftpput -u gleason -p my.password Elwood.probe.net /home/gleason stuff.txt
  ncftpput -u gleason Elwood.probe.net /home/gleason a.txt (prompt for pass)
  ncftpput -a -u gleason -p my.password -m -U 007 Bozo.probe.net /tmp/tmpdir a.txt
  tar cvf - /home | ncftpput -u operator -c Server.probe.net /backups/monday.tar

以防有人感兴趣,这里是完成的脚本。它所做的只是连接到一个简单的php脚本来确定我的远程IP。(这由cron作业每隔几分钟完成一次)。它将找到的IP与上次存储IP地址的文件进行比较。如果更改了,它会将IP保存在比较文件“file1.txt”中,并将FTP文件保存到ISP托管的Web空间中。计划是,我可以使用IP作为重定向页面的变量,或者只是检查我最近的IP

#!/bin/bash 
# Check IP address compare to see if its changed.
# Save the file to a couple of different places locally
# FTP the file to regular hosting.
# File to keep IP address in
IP_FILE=file1.txt
echo "File to store and compare IP:" $IP_FILE
# wget to check current IP address.
IPADDRESS=$(wget URL/ip.php -O - -q)
echo "New IP:" $IPADDRESS
# Read the previous IP address from file
source $IP_FILE
echo "Old IP:" $OLD_IP
# Compare the new to the old IP
if [ "$IPADDRESS" != "$OLD_IP" ]
then
    echo "New IP address detected: $IPADDRESS"
    # Write new address to file
    `echo "OLD_IP=$IPADDRESS" > $IP_FILE`

    # FTP File to the appropriate places
    # Store it locally as well
    ncftpput -u user -p pass webspace.co.uk /remotefiletostorein/ /local/file/tostore.php

fi
请注意,我不知道这样做的安全风险,因为现在这并不重要,但请注意。不要使用这个,除非你知道你在做什么,我不承担任何责任,这是不安全的lol


不过,它确实为您提供了一个动态托管等备份解决方案。

您能够运行
wput-v file.php吗ftp://usr:pass@host.co.uk/docroot/
单独在一个shell中?另外,你在使用Windows吗?在看到“\r”之后,我强烈怀疑Windows文件下线问题。我不使用Windows,我使用的机器是UBUNTU[Linux]。奇怪的是,如果文件不存在于另一个Web主机上,它就可以工作。但一旦它出现,它就会再次跳过。我想我需要强制覆盖它:找不到包ncftpput这是ubuntu linux顺便说一句啊看起来你是指ncftp?这就像一个咒语
ncftpput-u user-p pass webspace.co.uk/remotefiletostorein//local/file/tostore.php