Use batch processing on Windows to copy files from a remote Linux server to a local

Source: Internet
Author: User

Use batch processing on Windows to copy files from a remote Linux server to a local


################################################

Install Cygwin to select the following installation package:

Autoconf2. , automake1.1, Binutil, Gcc-cor,

Gcc-g, GD, Pcre, Pcre-devel, make, vim,expect (expect is required to enter the password automatically when using SCP)

Image file Selection: Http://cygwin.mirror.globo.tech


#################################################


1. Setting the Windows System environment variables

Add/cygwin64/home/admin;/cygwin64/bin to the front of the Windows System environment variable path

2, in the/cygwin64/home/admin script 101.sh, the content is as follows:

#!/bin/expect-f

#set Password 123456

Set date [exec date-d "-2 Day" "+%y%m%d"]

Set FD [Open/home/admin/passwd.txt R]

Set password [Read $FD]

Close $FD

Spawn Scp-r [Email protected]:/tmp/nagiosa_${date}.tar/home/admin/log/

Set Timeout 300

Expect "[email protected] ' s password:"

Set Timeout 300

Send "$password \ r"

Set Timeout 300

Send "exit\r"

Expect EOF

3. password file

Vi/home/admin/passwd.txt

123456

4, write the batch file 101.bat on Windows, the content is as follows:

Expect-f c:\cygwin64\home\admin\101.sh

Expect-f c:\cygwin64\home\admin\201.sh (steps to be performed like this can be added down)

Pause

###########################


Use batch processing on Windows to copy files from a remote Linux server to a local

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.