mac下使用jenkins

连接ftp服务器

man ftp 可以看到有这些信息。 NAME ftp -- Internet file transfer program

SYNOPSIS ftp [-46AadefginpRtvV] [-N netrc] [-o output] [-P port] [-q quittime] [-s srcaddr] [-r retry] [-T dir,max[,inc]] [[user@]host [port]] [[user@]host:[path][/]] [file:///path] [ftp://[user[:password]@]host[:port]/path[/][;type=X]] [http://[user[:password]@]host[:port]/path] [...] ftp -u URL file [...] 连接服务器的话基本上就用到上面的讯息了。原本没有看man手册,一直使用 ftp user@xxx.com port 每次都要输入密码。后来还是用了下面这个更加简单的 ftp ftp://User:Passwd@xxx.com:port

浏览文件

命令和Windows、Linux的命令基本相同 ftp> cd Documents ftp> ls
ftp> dir

下载上传文件

put filename - Upload a file to the server

get filename - Download a file from the server

mput filename - Put multiple files on the server

mget filename - Get multiple files on the server

断开连接

bye:中断与服务器的连接。 ftp> bye


大部分的命令如下,可敲入man ftp获得

ls – list the contents of a directory on the FTP server cd – change the working directory on the FTP server pwd – show the current directory on the FTP server get – download files from the FTP server put – upload files to the FTP server account – include a password with your login information bye – terminate an ftp session and close ftp (or use disconnect to simply terminate a session) bell – make a cute sound after each file transfer is done chmod – change permissions delete – your guess is as good as mine (OK, you got me, it’s to delete a file off the server) glob – enable globbing hash – only functional in Amsterdam help – get help lpwd – print the local working directory for transfers mkdir – create folders on the FTP server rmdir – delete folders from the FTP server newer – only get a file if it’s newer (great for scripting synchronizations) nmap – use positional parameters to set filenames passive – use FTP passive mode prompt – allows the use of letters to automate answers to prompts rate – limit the speed of an upload or download

关于ftp,你甚至还可以写脚本进行文件操作,比如

#!/bin/bash
ftp -d krypted.com << ftpEnd
prompt
cd /Library/WebServer/Documents
put “*.html”
put “*.php”
cd /Library/WebServer/Documents
put “*.png”
quit
ftpEnd

#!/bin/bash
ftp -d krypted.com << ftpEnd
prompt
cd /My/Documents
get “*.doc”
quit
ftpEnd

在你的脚本中,可以使用以下几个字符获取一些特定的变量:

%/ – the current working directory of the FTP server
%M – the hostname of the FTP server
%m – the hostname only up to the .
%n – the username used for the FTP server

用Putty实现Linux与Windows互传文件

用Putty实现Linux与Windows互传文件

一般Linux与Windows大都使用FTP或者wget之类的工具来传输文件,Linux与Linux之间互传文件则使用scp工具。

scp(secure copy)确实是个好东西,用于在Linux下进行远程拷贝文件的命令,和它类似的命令有cp,不过cp只是在本机进行拷贝不能跨服务器,而且scp传输是加密的:

本地上传文件至服务器:

scp 本地文件名 远程用户名@远程IP地址:路径/新文件名; 例:scp AA.zip test@200.100.0.1:www/AA_new.zip; 从远程服务器下载文件至本地:

scp 远程用户名@远程IP地址:路径/新文件名 本地文件名; 例:scp test@200.100.0.1:www/AA.zip AA_new.zip; 这对于linux与linux之间互传是非常方便的。

如果从一台Windows机器要传输数据到一台仅开SSH服务的Linux服务器时,pscp就要发挥威力了。

PSCP和SCP功能相同,是putty的一个附加程序,一般在putty的目录下可以找到。pscp.exe只有一个文件,(将pscp.exe放到C:\WINDOWS\system32下就能直接在命令行下使用pscp命令了)。语法与scp相同,下面是几个有用的options。

pscp [options] source [source…] [user@]host:target

-p 拷贝文件的时候保留源文件建立的时间。 -q 执行文件拷贝时,不显示任何提示消息。 -r 拷贝整个目录 -v 拷贝文件时,显示提示信息。 例如我要将windows上的一个zip包通过SSH服务传输到Linux服务器上可以这样做:

D:PROGRA~1Putty>pscp -pw mypasswd “E:/TDDOWNLOAD/Discuz!_6.0.0_SC_GBK.zip” Holmesian@192.168.128.128:. Discuz!_6.0.0_SC_GBK.zip | 3711 kB | 1855.6 kB/s | ETA: 00:00:00 | 100% 相应的从Linux服务器上下载文件只需要将目标和源反过来即可。