0501. [LINUX] (ssh) while read 이용 자동 명령실행하기
IT2016. 2. 26. 09:47
#!/bin/sh
while read server #◀ 읽어올 행이 더이상 없는 경우는 리턴값이 1이 되므로 그 지점에서 while 문 종료함.
do
ssh -n $server "$@" #◀ ssh -n옵션으로 ssh 커맨드에 표준입력을 실행하지 않도록 지정함
done
[root@linuxtest kim]# ./t5.sh hostname < server.txt
[root@linuxtest kim]# cat server.txt
root@10.20.12.58
root@10.20.12.148
root@10.20.12.37
root@10.20.12.83
root@10.20.12.51
root@10.20.12.52
root@10.20.12.144
'IT' 카테고리의 다른 글
0503. [CentOS] iptables 방화벽 예제 (0) | 2016.02.26 |
---|---|
0502. [LINUX] (while wait &) while 문에서 file 읽어오기와 병렬실행 후 wait 하기 (0) | 2016.02.26 |
0500. [LINUX] (ssh) 기본패턴과 파이프라인 ssh 자동접속하기 (0) | 2016.02.26 |
0499. [Linux] (ssh) ssh 암호없이 접속하기 (0) | 2016.02.25 |
0498. [CentOS] (ssh) linux centos 에서 ssh 명령어 사용하기 (0) | 2016.02.25 |