問題文
パスワード(スクリプトに記載されています)を聞かずにサーバーにアクセスし、そのサーバーでコマンドを実行したいと思います。
私のコード
#!/usr/bin/expect
spawn sudo su - <server_name>
expect "[sudo] password for chronicles:"
set Password "xxxxxxx"
send "$Password\r"
#set timeout 300
send "whoami\r"
send "ls -ltr\r"
expect eof
出力
invalid command name "sudo"
while executing
制限
- 環境変数を変更したり、.bash_profile/.bashrcを変更したりするためのアクセス権がありません。
- suserver_nameコマンドは許可されていません