1. ftp automatically logs in to batch download files.
Copy codeThe Code is as follows: ##### migrate/home/data from 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.
Copy codeThe Code is as follows: #### 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.
Copy codeThe Code is as follows: #### 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.
Copy codeThe Code is as follows: #### set 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.