Automatic synchronization of files between Windows and Linux

Source: Internet
Author: User
Tags ftp commands terminates

Problem: When you encounter a scene at work, you need to automatically sync the files on your Linux machine to your Windows machine on a daily schedule.

The solution has two:

1, set up the shared directory on the Windows machine, then mount the shared directory on the Linux machine and write the files to the shared directory every day.

Command: mount-t cifs-o username=administrator,password=xxx//win ip/windows shared directory name/sample/

2. Build an FTP server on Linux and then download the files on Windows via timed task execution scripts.

The first scenario requires a login password for Windows. This article uses a second scenario.

FTP Operations on Windows:

In dir access directory times wrong:

PORT command successful. Consider using PASV.
425 Failed to establish connection.

Solution: Perform the following two commands on Windows.

1)netsh advfirewall firewall add rule name="FTP" dir=in action=allow program=%SystemRoot%\System32\ftp.exe enable=yes protocol=tcp

2)netsh advfirewall firewall add rule name="FTP" dir=in action=allow program=%SystemRoot%\System32\ftp.exe enable=yes protocol=udp

The script files that are executed on Windows through a timed task are as follows. Download the staspowerpre.csv to the C:/mltemp directory.

@echo offset ftpulr=192.xxx.xxx. Xxxset ftpuser=ftp_testset ftppwd=000000set Ftpport=21echo open%ftpulr%%ftpport%>>openftp.txtecho%ftpuser% >>openftp.txtecho%ftppwd%>>openftp.txtecho prompt Off>>openftp.txtecho mget staspowerpre.csv c:// Mltemp//staspowerpre.csv >>openftp.txtecho Bye>>openftp.txtecho Transport data......ftp-s:o Penftp.txtdel Openftp.txtexit

FTP Upload and download under Windows system and some common commands

First assume an FTP address user name password

FTP Server:home4u.at.china.com

User:yepanghuang

Password:abc123

Open the Windows Start menu, execute the "Run" command, enter FTP in the dialog, press "OK" button will switch to DOS window, a command prompt appears

ftp> Type the command to connect to the FTP server:

Ftp> Open home4u.at.china.com (carriage return)

Wait a moment, the screen prompts the connection to succeed:

Ftp> connected to Home4u.china.com

Then the server asks the user name and password, enter Yepanghuang and abc123, respectively, to be certified.

FTP Upload files under windows:

For example, to upload the d:/index.html to the root of the server, you can type:

Ftp> put d:/index.html (carriage return)

When the screen prompts you to complete the transfer, you can type the relevant command to view:

ftp> dir (carriage return)

FTP upload download under windows:

Suppose you want to download all the. jpg files from the server/images directory to this computer, you can enter the instructions:

ftp> CD images (carriage return) [Note: Enter/images directory]

Ftp> mget *.jpg

Under Windows FTP upload and download work completed, type bye interrupt connection.

Ftp> Bye (carriage return)

Here are some common FTP commands:

1. Open: Connect to the server;

2. Send (Put): Upload files;

3. Get: Download files;

4. mget: Download multiple files;

5. CD: Switch directory;

6. Dir: View the files in the current directory;

7. del: Delete files;

8. Bye: Interrupts the connection to the server.

If you want to learn more, you can type

ftp> Help (carriage return)

To view the command set:

ASCII: Set to transfer files in ASCII mode (default value)

Bell: Every time a file transfer is completed, Alarm prompts

Binary: Set to transfer files in binary mode

Bye: Terminates the host FTP process and exits the FTP management mode

Case: When on, the file name copied with the Mget command to the local machine, all converted to lowercase letters

CD: cd command with UNIX

Cdup: Return to the top level directory

chmod: Changing file permissions for remote hosts

Close: Terminates the remote FTP process, returns to the FTP command state, and all macro definitions are deleted

Delete: Remove files from the remote host

dir [remote-directory] [Local-file]: Lists the files in the current remote host directory. If you have a local file, write the results to a local file

get [Remote-file] [Local-file]: Transfer from the remote host to the local host

Help [command]: Explanation of OUTPUT commands LCD: Change the working directory of the current local host, if default, go to the current user's home directory

LS [remote-directory] [local-file]: With dir

Automatic synchronization of files between Windows and Linux

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.