前提・実現したいこと
expectコマンド内でawkを使いたい。
awk内のprintオプションが単独コマンドとして認識されてしまっていて、うまくいっていない様子。
どなたか助けてください、、、
発生している問題・エラーメッセージ
argv[0] = expect argv[1] = -d argv[2] = -c argv[3] = set timeout 60 spawn sudo su expect ":" send "abcde\n" expect "#" send "\cp /tmp/hoge-1.2.3.jar /opt/hoge/lib/\n" expect "上書きしますか?" send "yes\n" expect "#" send "ps -ef | grep /opt/hoge/lib/hoge-*.jar | grep -v grep | awk { argv[4] = print argv[5] = kill -9, argv[6] = $2} \n" set argc 2 set argv0 "print" set argv "{kill -9,} $2\}\ \n\"\n" executing commands from command file print couldn't read file "print": no such file or directory
該当のソースコード
shell
1#!/bin/bash -xe 2 3target_path=/tmp/hoge.jar 4awk_command="awk '{ print \"kill -9\", \$2}'" 5 6ssh -t -t wif_adm_y.sato@192.168.83.75 "expect -d -c ' 7 8 set timeout 60 9 spawn sudo su 10 expect \":\" 11 send \"abcde\n\" 12 expect \"#\" 13 send \"\cp $target_path /opt/hoge/lib/\n\" 14 expect \"上書きしますか?\" 15 send \"yes\n\" 16 expect \"#\" 17 send \"ps -ef | grep /opt/hoge/lib/hoge-*.jar | grep -v grep | $awk_command \n\" 18 19'" 20上記コードの最終行のsendがうまくいっておりません、、、
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/08/08 03:51
2018/08/15 04:04