FTP Automatic Execution example

Source: Internet
Author: User
Using command line FTP on Linux or windows and executing it automatically on a regular basis is a very practical function that can improve work efficiency.

Linux:Use an execution script auto_ftp.sh :#! /Bin/sh

Cd/home/user1/

Ftp-I-n <FTPIT
Open 10.1.9.201 21
User username password
Cd bakdir
Bin
Prompt
Mget *. BAK
Bye
Quit
FTPIT

Exit

You can modify the Italic content based on the actual situation.
Note:
1. If there are shell special characters such as @, #, $, and % in username and password, escape them before the character, for example, 123 @ 346 $ as 123 @ 346 $.
2. prompt starts a switch function to control interaction prompts. If FTP is set to Interactive mode off, do not write prompt; otherwise, add prompt.

The following is an example of the get backup file script get_bak.sh:

#! /Bin/sh

CD/home/user1/
# Rename the old backup file first
For I in $ (find.-Name "DB _ *. Bak"); Do MV $ I. Old; done

# Determine whether auto_ftp.sh is successfully executed
If./auto_ftp.sh 2>/dev/null
Then

# Determine whether the latest backup file is a 0-byte empty file
If [[-s dB _ 'date + % Y % m % d '0400. Bak]
Then
# Echo "not 0"
# A valid backup file is successfully obtained. Delete the old backup file,
RM *. Old
Fi
Fi

Windows:Run the following command:

FTP-n-s: "G:/dbbak/1.ftp"

1. ftp is an ftp command control file in the following format:

Open 10.1.9.201 21
User Username Password
Bin
Prompt
Mput *. dmp
Mput *. SQL
Mput *. bat
Bye
Quit
Exit

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.