1. FTP automatically logs in to batch download files.
##### From/home/data on the FTP server 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 logs on to upload files.
#### Local/home/databackup to/home/data on the 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 automatically logs in to download a single file.
#### Download/home/data/a. Sh to local/home/databackup on the FTP server ####
#! /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 automatically logs on to upload a single file.
#### Put local/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 preceding script as a file and add it to crontab to automatically upload and download files through FTP.
Note:
1.-N is not affected by the. netrc file. (FTP reads the settings in the. netrc file by default)
2. <uses the instant file redirection input.
3 .! It must appear in pairs to mark the beginning and end of an instant file.
From http://liwenge.iteye.com/blog/566515