zoukankan      html  css  js  c++  java
  • scp命令写成脚本

    scp.sh

    #!/usr/bin/expect -f
    set port 1234
    set user "me"
    set host "192.168.1.2"
    set password "whatismypassword"
    set timeout - 1
    set file [ lindex $argv 0]
    set hostFilePath "/home/me/"
    spawn scp -P$port $file $user@$host:$hostFilePath
    expect "*assword:*"
    
    send "$password
    "
    expect eof
    每次敲scp命令,蛋疼的用户名,蛋疼的超复杂的密码,蛋疼的长长的路径。写成这样,自动执行,超爽
     
    ./scp.sh text.txt
    就把test.txt传到远程的机器
     
    expect,传参的话,用[lindex $argv 0],这里的0表示text.txt。刚开始还以为是1,所以一直取不到
    spawn是expect的内建命令,需要chmod 755 scp.sh
     
  • 相关阅读:
    实用产品规划
    产品经理对用户的调研
    产品经理用户研究
    竞品分析方案
    产品竞品分析
    Mybatis Plus
    shiro
    Spring cloud
    Spring Boot
    Redis入门(二)
  • 原文地址:https://www.cnblogs.com/yemsheng/p/3211940.html
Copyright © 2011-2022 走看看