请问一下我在脚本中如何才能调取ip.txt中的值。我大概知道使用for语句,但具体的语句编写一直不成功。请教大家一下,我该怎么写。

[root@tst scripts]# cat ip.txt
192.8.151.72
192.8.151.73
192.8.151.74
192.8.151.75
192.8.151.76
192.8.151.77
192.8.151.78
vim /scripts/tst.sh
#!/bin/bash
 2
 3 /usr/local/bin/expect <<-EOF
 4 set ip[lindex $argv 0]
 5 spawn ssh -p22 root@$ip
 6 expect {
 7 "*yes/no" { send "yes\r"; exp_continue }
 8 "*password:" { send "passwd\r" }
 9 }
10 expect "*#"
11 send "cd /\r"
12 expect "*#"
13 send "chown tst.users /Tstapp\r"
14 expect "*#"
15 send "exit\r"
16 expect eof
17 EOF


  • 就几件    2020-04-03 15:40:17
  • 阅读 765    收藏 0    回答 1
  • 邀请
  • 收藏
  • 分享
发送
登录 后发表评论
  • 51testing软件测试圈微信