Archive for March 11, 2016

Linux mount the ftp server

Linux mount the ftp server,You need to use a package called the fuse-curlftpfs。Under normal circumstances can not get this package through yum way,Therefore, you need to install DAG repository

Centos5 64位 wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el5.rf.x86_64.rpm
Centos5 32位 wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el5.rf.i386.rpm
Centos6 64位 wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
Centos6 32位 wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.i686.rpm
Then install the downloaded rpm package

rpm -ivh rpmforge-release-0.5.3-1.el5.rf.x86_64.rpm
Then you can install the fuse-curlftpfs the way through yum

yum install fuse-curlftpfs -y
Execute this command on Centos6,Requires might encounter: libcurl.so.3 error,Solution:Edit /etc/yum.repos.d/rpmforge.repo file,The [rpmforge-extras] Open item,It can then execute yum clean all。

Then you can mount the ftp

Written 1:curlftpfs ftp://username:Password @ftp address mount point -o codepage = utf8
Writing 2:curlftpfs ftp://ftp address mountpoint -o user =”username:password”
note:If you prompted to "fuse: failed to open /dev/fuse: Operation not permitted”,That you are using the Linux VPS OpenVZ technology,OpenVZ technology because of defective (all common hen chicks kernel) unusable curlftpfs command,Please use vmware or Xen technology。

Boot automatically mount

echo “curlftpfs # Username:Password @ftp address mount point fuse rw,allow_other,uid=0,gid=0 0 0” >> /etc/fstab

Comments

linux files download ftp several ways

one、The easiest way: wget
All files following command to download a specified directory on the ftp server
[html] view plain copy print?
wget ftp://IP:PORT/* –ftp-user=xxx –ftp-password=xxx -r
-r parameter represents a recursive downloads;
can use–directory-prefix = / mypath / designated storage path download;-nH option can not create the directory structure on the local server
Another option is confusing–delete-after,It is not to remove the downloaded file on the server,But to remove the machine;
The reason is wget wget instead wput,It can only download operation,On the ftp server does not support any write operation,For example, delete。
two、The method can delete files:lftp
Project requirements are specified file all the files on the ftp server download gripping inside,After downloading and delete,wget not meet the requirements,Then rewrite the script below。
mget command to download multiple files,-Delete files on the server after downloading E parameter indicates。
[python] view plain copy print?
#!/bin/bash
#ip designated ftp server
serverip=1.2.3.4
#ftp ftp server specified by the user
serveruser=root
#ftp user password specified ftp server
serverpass=123456
#Specifies the client to download a host of local file directory
localdir=./data
logfile=../log/ftp_download.log
#Specify the server host ftp directory
remotedir=./
#Host Name Specify the host server
host=test_host
#Switch to local download file directory
cd $localdir
#Enter the information to start the backup
echo “Starting FTP Download on ” $host
#Ftp server connection
/usr/bin/lftp << EOF open $serverip user $serveruser $serverpass #切换到server主机的ftp目录 echo "cd " $remotedir cd $remotedir #列出ftp服务器ftp目录中文件列表并存放到client中的$localdir中 ls . >> $logfile
#Ftp download ftp server directory of all files
mget -E *.txt
#Exit ftp server
bye
three、Other methods
System ftp command,And strong curl。
curl支持FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP,Easy call in your program。Supports cookie、proxy、Password and certificate validation。Very powerful。

Comments