Summary of code for automatically uploading and downloading ftp using Shell scripts in Linux

Source: Internet
Author: User

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.

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.