calisto
V2EX  ›  Bash

shell 脚本用 expect 输入密码,密码带有{}导致 expect 报错

  •  
  •   calisto · Sep 29, 2019 · 7899 views
    This topic created in 2448 days ago, the information mentioned may be changed or developed.
    P="sw{sdw[@><K]}" 这是密码


    /usr/bin/expect<<EOF
    set timeout -1
    spawn bash -c "rsync -av --inplace --delete --progress \"-e ssh -p ${bills_bak_port}\" $Sdir $U@$H:$Ddir"
    expect {
    "(yes/no)?" {send "yes\r";exp_continue}
    "password:" {send "$P\r"}
    }
    expect eof
    EOF
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2970 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 04:48 · PVG 12:48 · LAX 21:48 · JFK 00:48
    ♥ Do have faith in what you're doing.