请问一下我在脚本中如何才能调取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