bash
  • command
  • title
  • expect
  • 2016-10-14 4 views 1 likes 
    1

    expecttitleでコマンドファイル(macOS)など(GNU/Linux)を実行するにはどうすればよいですか?私は追加することができますどのようにこのためのこのコマンドファイル:Expect + Title。これどうやってするの?

    title='My first title' 
    echo -n -e "\033]0;$title\007" 
    

    はあなたが構文を使用する必要が

    #!/usr/bin/expect -f 
    
    title='My first title' 
    echo -n -e "\033]0;$title\007" 
    
    set timeout -1 
    
    spawn rm -rf /path/to/.ssh/known_hosts 
    
    spawn ssh [email protected] 
    expect "?" 
    send "yes\r" 
    expect "assword:" 
    send "thepassword\r" 
    expect "thenamemachine:~#" 
    send "bash <(curl -s aFile.sh)\r" 
    interact 
    

    答えて

    1

    動作しません

    #!/usr/bin/expect -f 
    
    set timeout -1 
    
    spawn rm -rf /path/to/.ssh/known_hosts 
    
    spawn ssh [email protected] 
    expect "?" 
    send "yes\r" 
    expect "assword:" 
    send "thepassword\r" 
    expect "thenamemachine:~#" 
    send "bash <(curl -s aFile.sh)\r" 
    interact 
    

    しかし:

    は今、私はこれを使用しますシェルではなく、期待するスクリプト。あなたが欲しい:

    set title "My first title" 
    send_user "\033]0;$title\007" 
    

    また、あなたがrm -rfと相互作用を持っている必要はありませんので、spawnの代わりにexecを使用します。

    exec rm -rf /path/to/.ssh/known_hosts 
    
    +0

    はどうもありがとうございました!そして、** exec ** tipの本当にありがとう! – DylanDog

    関連する問題