windows、linux互传文件

2、常用的为上传下载

1)、get

从远程服务器上下载一个文件存放到本地,如下:

先通过lcd切换到本地那个目录下,然后通过get file

>> lcd d:\            #表示切换到本地的d盘下

>> get ./test.sql   #这样就将当前文件下载本地的d盘下

2)、put

是将本地的文件上传到远程服务器上,如下:

>> put               #在windows下弹出选择文件的窗口

3)、lcd

先通过lcd切换到本地那个目录下

>> lcd c:\            #表示切换到本地的c盘下

4)、lls

#显示当前目录下的所有文件

5)、pwd

#显示当前目录

 

三、各个用法实例详解

实例1、从服务器下载文件到本机

Xshell 5 (Build 0806)

Copyright (c) 2002-2015NetSarang Computer, Inc. All rights reserved.

Type `help' to learn howto use Xshell prompt.

[c:\~]$

Connecting to192.168.56.101:22...

Connection established.

To escape to local shell,press 'Ctrl+Alt+]'.

Your current localdirectory is

C:\Users\FieldYang\Documents\NetSarang\Xshell\Sessions

Type `help' to browseavailable commnands.

sftp:/root> cd /mnt/share 

#远程路径切换为/mnt/share 

sftp:/mnt/share> ls –lt  

drwxrwxrwx   1 1000    users       4096 Jun 16 13:39 .

drwxr-xr-x   7 root    root        4096 Jun 15 14:06 ..

-rwxrwxrwx   1 1000    users     220151 Jun 15 14:26.goutputstream-ZHJ8IY

-rwxrwxrwx   1 1000    users      19362 Jun 16 12:270.jpg

-rwxrwxrwx   1 1000    users      16157 Jun 16 13:39Auth Server and SOAP proxy.docx

-rwxrwxrwx   1 1000    users      63952 Jun 16 12:29bamquickinstall.pdf

-rwxrwxrwx   1 1000    users       7277 Jun 16 13:33DNSmmmS.txt

-rwxrwxrwx   1 1000    users       7277 May 12 10:43DNSS.txt

-rwxrwxrwx   1 1000    users     111395 Jun 15 15:46libpcap-0.9.4-15.el5.x86_64.rpm

-rwxrwxrwx   1 1000    users     363677 Jun 15 14:59ppp-2.4.4-14.1.rhel5.x86_64.rpm

-rwxrwxrwx   1 1000    users      48430 Jun 15 14:57ppp-devel-2.4.4-14.1.rhel5.x86_64.rpm

-rwxrwxrwx   1 1000    users      86211 Jun 15 15:38pptpd-1.4.0-1.rhel4.x86_64.rpm

-rwxrwxrwx   1 1000    users      86509 Jun 15 14:46pptpd-1.4.0-1.rhel5.x86_64.rpm

-rwxrwxrwx   1 1000    users     220151 Jun 15 13:22Screenshot.png

-rwxrwxrwx   1 1000    users      21789 Jun 16 13:39Traffic Usage System alarm handling - Gateway, RadiusGWProxy, RadiusProxyServer.docx 

sftp:/mnt/share> lcd d:\Field\test_sftp 

#切换到本地的d盘下Field文件夹的test_sftp文件夹

Local directory is nowd:\Field\test_sftp

sftp:/mnt/share> lpwd

Local directory isd:\Field\test_sftp

#打印本地文件夹路径

sftp:/mnt/share> lls

06/16/2016 05:44¤W   <DIR>             .

06/16/2016 05:44¤W   <DIR>             ..

#查看本地文件夹d:\Field\test_sftp内容

sftp:/mnt/share>get ./0.jpg ./DNSmmmS.txt./pptpd-1.4.0-1.rhel5.x86_64.rpm

#下载远程服务器/mnt/share上的0.jpg、DNSmmmS.txt、#pptpd-1.4.0-1.rhel5.x86_64.rpm到本地文件夹d:\Field\test_sftp中

 

Fetching/mnt/share/./pptpd-1.4.0-1.rhel5.x86_64.rpm to pptpd-1.4.0-1.rhel5.x86_64.rpm

sftp: received 84.4 KB in0.64 seconds

Fetching/mnt/share/./DNSmmmS.txt to DNSmmmS.txt

sftp: received 7.10 KB in0.02 seconds

Fetching/mnt/share/./0.jpg to 0.jpg

sftp: received 18.9 KB in0.03 seconds 

sftp:/mnt/share> lls –lt

#命令行查看是否下载成功

06/16/2016 05:47¤W   <DIR>             .

06/16/2016 05:47¤W   <DIR>             ..

06/16/2016 05:47¤W               19362 0.jpg

06/16/2016 05:47¤W                7277 DNSmmmS.txt

06/16/2016 05:47¤W               86509 pptpd-1.4.0-1.rhel5.x86_64.rpm

windows、linux互传文件

实例2、上传本地文件到远程服务器

sftp:/mnt/share> lcd d:\Field\SNINF\

#切换本地路径到d:\Field\SNINF\

Local directory is nowd:\Field\SNINF\

sftp:/mnt/share> lpwd

#打印本地当前路径

Local directory isd:\Field\SNINF\

sftp:/mnt/share> lls -lt

02/19/2016 07:50¤W   <DIR>             .

02/19/2016 07:50¤W   <DIR>             ..

12/11/2015 08:27¤W               16157 Auth Server and SOAP proxy.docx

12/11/2015 08:27¤W              464191 Check Plan--Jacky.docx

12/11/2015 08:27¤W              562801 CIMDB ¡V David.docx

12/11/2015 08:27¤W               12031 Disk Full ¡V For All Systems.docx

12/11/2015 08:27¤W              126440 EMMSC--Fox.docx

12/11/2015 08:27¤W              115928 ENUM ¡VJacky.docx

12/11/2015 08:27¤W              327650 F-Secure.docx

12/11/2015 08:27¤W              107606 GDS--Fox.docx

12/11/2015 08:27¤W              117762 GIMEI¡XFox.docx

12/11/2015 08:27¤W              310862 GUP CGUP ¡ΠRay.docx

12/11/2015 08:27¤W              650939 IP call --Sharon.docx

12/11/2015 08:27¤W              779957 Mex health check--Niker.docx

12/11/2015 08:27¤W              124195 NetScout (DPI)¡XFox.docx

12/11/2015 08:27¤W              198426 POC--Jacky.docx

12/11/2015 08:27¤W              326368 Radius Proxy -Niker.docx

12/11/2015 08:27¤W              190044 SMTP health check--Niker.docx

12/11/2015 08:27¤W               45643 Stretti DFS¡XSharon.docx

12/11/2015 08:27¤W              233654 Stretti DISC ¡VJacky.docx

12/11/2015 08:27¤W              449498 Traffic Router Health Check¡XDavid.docx

12/11/2015 08:27¤W               21789 Traffic Usage System alarm handling -Gateway, RadiusGWProxy, RadiusProxy Server.docx

12/11/2015 08:27¤W              734859 Video Transcoder¡XDavid.docx

12/11/2015 08:27¤W               14815 Virtual Browser.docx

12/11/2015 08:27¤W               22554 ZMMSC.docx

12/11/2015 08:27¤W              219776 ZProxy ¡ΠFox.docx

12/11/2015 08:27¤W              221199 ZWAPGW NZWAPGW ¡ΠFox.docx 

sftp:/mnt/share> put

Uploading Traffic UsageSystem alarm handling - Gateway, RadiusGWProxy, RadiusProxy Server.docx toremote:/mnt/share/Traffic Usage System alarm handling - Gateway, RadiusGWProxy,RadiusProxy Server.docx

sftp: sent 21.2 KB in 0.01seconds

#在弹出的Windows框中选择文件上传 注意上传路径与当前路径要相同 

sftp:/mnt/share> put

Uploading VirtualBrowser.docx to remote:/mnt/share/Virtual Browser.docx

sftp: sent 14.4 KB in 0.02seconds

sftp:/mnt/share> put

Uploading CheckPlan--Jacky.docx to remote:/mnt/share/Check Plan--Jacky.docx

sftp: sent 453 KB in 0.05seconds

sftp:/mnt/share> put

Uploading ZMMSC.docx toremote:/mnt/share/ZMMSC.docx

sftp: sent 22.0 KB in 0.00seconds

sftp:/mnt/share> ls -lt

drwxrwxrwx   1 1000    users       4096 Jun 16 13:54 .

drwxr-xr-x   7 root    root        4096 Jun 15 14:06 ..

-rwxrwxrwx   1 1000    users     220151 Jun 15 14:26.goutputstream-ZHJ8IY

-rwxrwxrwx   1 1000    users      19362 Jun 16 12:270.jpg

-rwxrwxrwx   1 1000    users      16157 Jun 16 13:39Auth Server and SOAP proxy.docx

-rwxrwxrwx   1 1000    users      63952 Jun 16 12:29bamquickinstall.pdf

-rwxrwxrwx   1 1000    users     464191 Jun 16 13:53Check Plan--Jacky.docx

-rwxrwxrwx   1 1000    users       7277 Jun 16 13:33DNSmmmS.txt

-rwxrwxrwx   1 1000    users       7277 May 12 10:43DNSS.txt

-rwxrwxrwx   1 1000    users     111395 Jun 15 15:46libpcap-0.9.4-15.el5.x86_64.rpm

-rwxrwxrwx   1 1000    users     363677 Jun 15 14:59ppp-2.4.4-14.1.rhel5.x86_64.rpm

-rwxrwxrwx   1 1000    users      48430 Jun 15 14:57 ppp-devel-2.4.4-14.1.rhel5.x86_64.rpm

-rwxrwxrwx   1 1000    users      86211 Jun 15 15:38pptpd-1.4.0-1.rhel4.x86_64.rpm

-rwxrwxrwx   1 1000    users      86509 Jun 15 14:46pptpd-1.4.0-1.rhel5.x86_64.rpm

-rwxrwxrwx   1 1000    users     220151 Jun 15 13:22Screenshot.png

-rwxrwxrwx   1 1000    users      21789 Jun 16 13:52Traffic Usage System alarm handling - Gateway, RadiusGWProxy, RadiusProxyServer.docx

-rwxrwxrwx   1 1000    users      14815 Jun 16 13:53Virtual Browser.docx

-rwxrwxrwx   11000    users      22554 Jun 16 13:54 ZMMSC.docx

sftp:/mnt/share>

 

实例3、在远程服务器创建删除目录

sftp:/mnt/share> mkdir /mnt/share/test

#在远程服务器上创建目录/mnt/share/test

sftp:/mnt/share> cd /mnt/share/test

sftp:/mnt/share/test> pwd

#查看是否创建成功

Remotedirectory is /mnt/share/test

sftp:/mnt/share/test> cd /mnt/share/

sftp:/mnt/share> rmdir /test

cannotremove /test: no such a directory

sftp:/mnt/share>rmdir /mnt/share/test

#删除刚创建的目录/mnt/share/test

sftp:/mnt/share> cd /mnt/share/test

cannotchange to /mnt/share/test: no such a directory

#确认是否删除成功

 

实例4、在远程服务器删除文件

sftp:/mnt/share> rm ./ZMMSC

#删除远程服务器/mnt/share上的文件ZMMSC.docx,./表示当前目录

cannotdelete /mnt/share/./ZMMSC: no such a file

sftp:/mnt/share> rm ./ZMMSC.docx

deleted/mnt/share/./ZMMSC.docx

sftp:/mnt/share> rm ./Traffic UsageSystem alarm handling - Gateway, RadiusGWProxy, RadiusProxy Server.docx

usage:rm file

sftp:/mnt/share> rm ./DNSS.txt

deleted/mnt/share/./DNSS.txt

sftp:/mnt/share> ls

#查看是否成功删除

drwxrwxrwx   1 1000    users       4096 Jun 16 14:25 .

drwxr-xr-x   7 root    root        4096 Jun 15 14:06 ..

-rwxrwxrwx   1 1000    users     220151 Jun 15 14:26.goutputstream-ZHJ8IY

-rwxrwxrwx   1 1000    users      19362 Jun 16 12:270.jpg

-rwxrwxrwx   1 1000    users      16157 Jun 16 13:39 AuthServer and SOAP proxy.docx

-rwxrwxrwx   1 1000    users      63952 Jun 16 12:29bamquickinstall.pdf

-rwxrwxrwx   1 1000    users     464191 Jun 16 13:53Check Plan--Jacky.docx

-rwxrwxrwx   1 1000    users       7277 Jun 16 13:33DNSmmmS.txt

-rwxrwxrwx   1 1000    users     111395 Jun 15 15:46libpcap-0.9.4-15.el5.x86_64.rpm

-rwxrwxrwx   1 1000    users     363677 Jun 15 14:59ppp-2.4.4-14.1.rhel5.x86_64.rpm

-rwxrwxrwx   1 1000    users      48430 Jun 15 14:57ppp-devel-2.4.4-14.1.rhel5.x86_64.rpm

-rwxrwxrwx   1 1000    users      86211 Jun 15 15:38pptpd-1.4.0-1.rhel4.x86_64.rpm

-rwxrwxrwx   1 1000    users      86509 Jun 15 14:46pptpd-1.4.0-1.rhel5.x86_64.rpm

-rwxrwxrwx   1 1000    users     220151 Jun 15 13:22Screenshot.png

-rwxrwxrwx   1 1000    users      21789 Jun 16 13:52Traffic Usage System alarm handling - Gateway, RadiusGWProxy, RadiusProxyServer.docx

-rwxrwxrwx   1 1000    users      14815 Jun 16 13:53Virtual Browser.docx

sftp:/mnt/share>

上一篇:2018-10-04 [日常]用Python读取word文档中的表格并比较


下一篇:如何使用php代码点火器读取docx文件数学方程式