Linux uses shell scripts to implement automatic FTP upload and download

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.