1. FTP automatically log in to bulk download files.
# # # # # # #从ftp服务器上的/home/data to the local/home/databackup####
#!/bin/bash
ftp-n<<!
Open 192.168.1.171
User Guest 123456
Binary
Cd/home/data
Lcd/home/databackup
Prompt
Mget *
Close
Bye
!
2. FTP automatically log in to upload files.
# # # #本地的/home/data#### on/home/databackup to FTP server
#!/bin/bash
ftp-n<<!
Open 192.168.1.171
User Guest 123456
Binary
Hash
Cd/home/data
Lcd/home/databackup
Prompt
Mput *
Close
Bye
!
3. FTP automatic login to download a single file.
# # # #ftp服务器上下载/home/data/a.sh to local/home/databackup####
#!/bin/bash
ftp-n<<!
Open 192.168.1.171
User Guest 123456
Binary
Cd/home/data
Lcd/home/databackup
Prompt
Get a.sh a.sh
Close
Bye
!
4. FTP automatic login to upload a single file.
# # # #把本地/home/databachup/a.sh up Ftp/home/databackup # # # #
#!/bin/bash
ftp-n<<!
Open 192.168.1.171
User Guest 123456
Binary
Cd/home/data
Lcd/home/databackup
Prompt
Put a.sh a.sh
Close
Bye
!
Summary: Save the above script as a file added to the crontab can be implemented automatically ftp upload, download files.
Annotations:
1.-N is not affected by the. netrc file. (FTP defaults to read the settings in the. netrc file)
2. << is using instant file redirection input.
3.! is the instant file flag it must appear in pairs to identify the start and end of the instant file.
Transfer from http://liwenge.iteye.com/blog/566515
Category: Linux/unix Tags: linux/unix_shell
Linux uses shell scripts for automatic ftp upload and download