V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
calisto
V2EX  ›  Bash

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

  •  
  •   calisto · Sep 29, 2019 · 7807 views
    This topic created in 2402 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   ·   3205 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 13:39 · PVG 21:39 · LAX 06:39 · JFK 09:39
    ♥ Do have faith in what you're doing.