Linux using shell script to implement FTP automatic upload download code summary _linux Shell

Source: Internet
Author: User

1. FTP automatically log in to bulk download files.

Copy Code code as follows:

# # # # # # # # # #从ftp服务器上的/home/data to 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 Automatic login upload file.

Copy Code code as follows:

### #本地的 the/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.

Copy Code code as follows:

### #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 automatically login to upload a single file.

Copy Code code as follows:

### #把本地/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: The above script saved as a file to add to the crontab can be implemented FTP automatic upload, download files.
Note:
1.-N is not affected by the. netrc file. (FTP defaults to reading the settings in the. netrc file)
2. << is using instant file redirection input.
3.! is the sign of an instant file it must appear in pairs to identify the start and end of an instant file.

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.