道歉我知道这是一个很好的问题,但我似乎找不到任何简单的解决方案......
试图解决问题并希望somone能够提供帮助。
我创建一个脚本,我能想到解决这个特定问题的唯一方法是通过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
有人能告诉我哪里出错了。这可能是文件权限问题吗?
我所需要的只是简单的解决方案,用于以简单的方式自动将文件从我的计算机传输到某个网络空间。
由于
答案 0 :(得分:1)
尝试使用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
答案 1 :(得分:0)
以防任何人对此感兴趣是完成的脚本。它只是连接到一个简单的PHP脚本来确定我的远程IP。 (这是每隔几分钟由一个cron工作完成的)。它将找到的IP与上次存储IP地址的文件进行比较。如果更改它将IP保存在比较文件" file1.txt"和FTP的文件由ISP托管的webspace完成。然后,我可以使用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
请注意我不知道这样做的安全风险,因为现在无所谓但请。除非你知道你在做什么,否则不要使用它,我不负责这是不安全的大声笑。
但它确实为您提供了动态托管等的备份解决方案。