如何查询百度收录情况,太原整站优化,云开发高级布道师,科技公司网站设计from linux下带密码的scp (2014-03-10 12:35:46)背景#xff1a; 需要将一台机器的数据传输到另外一台机器上#xff0c;两台机器没有信任关系#xff0c;没有数据源一方没有ftp或者http#xff0c;无法进行wget 解决方法#xff1a; 在其中一台机器安装expect#xff0c…from linux下带密码的scp (2014-03-10 12:35:46)背景 需要将一台机器的数据传输到另外一台机器上两台机器没有信任关系没有数据源一方没有ftp或者http无法进行wget 解决方法 在其中一台机器安装expect在程序中写上密码等信息 准备 需要root权限 进行expect安装 expect安装步骤 A. Tcl 安装 主页: http://www.tcl.tk 下载地址: http://www.tcl.tk/software/tcltk/downloadnow84.tml1.下载源码包wget http://nchc.dl.sourceforge.net/sourceforge/tcl/tcl8.4.11-src.tar.gz2.解压缩源码包tar xfvz tcl8.4.11-src.tar.gz3.安装配置cd tcl8.4.11/unix./configure --prefix/usr/tcl --enable-sharedmakemake install安装完毕以后进入tcl源代码的根目录把子目录unix下面的tclUnixPort.h copy到子目录generic中。暂时不要删除tcl源代码因为expect的安装过程还需要用。B. expect 安装 (需Tcl的库)主页: http://expect.nist.gov/1.下载源码包wget http://sourceforge.net/projects/expect/files/Expect/5.45/expect5.45.tar.gz/download2.解压缩源码包tar xzvf expect5.45.tar.gz3.安装配置cd expect5.45./configure --prefix/usr/expect --with-tcl/usr/tcl/lib --with-tclinclude../tcl8.4.11/genericmakemake installln -s /usr/tcl/bin/expect /usr/expect/bin/expectexpect脚本#!/usr/bin/expectset timeout 10set host [lindex $argv 0]set username [lindex $argv 1]set password [lindex $argv 2]set src_file [lindex $argv 3]set dest_file [lindex $argv 4]spawn scp $src_file $username$host:$dest_fileexpect {(yes/no)?{send yes\nexpect *assword: { send $password\n}}*assword:{send $password\n}}expect 100%expect eof#!/bin/shlist_file$1src_file$2dest_file$3cat $list_file | while read linedohost_ipecho $line | awk {print $1}usernameecho $line | awk {print $2}passwordecho $line | awk {print $3}echo $host_ip./expect_scp $host_ip $username $password $src_file $dest_filedone