|
| |
|
°Ô½Ã¹° 42°Ç
|
|
|
[½ºÅ©¸³Æ®] expect ¸¦ ÀÌ¿ëÇؼ Æнº¿öµå ¾øÀÌ ¿ø°Ý ÀÛ¾÷ ÁøÇàÇϱâ [´ÜÀÏ & ´ÙÁß] |
|
±Û¾´ÀÌ :
ÃÖÀå¼·
³¯Â¥ : 2015-04-22 (¼ö) 17:14
Á¶È¸ : 7081
|
- SSH-KEYGEN À» »ç¿ëÇÏÁö ¾Ê°í Æнº¿öµå¸¦ ¾Ë°í ÀÖ´Â »óȲ¿¡¼ ¿ø°ÝÀ¸·Î ÀÛ¾÷À» ³»¸± ½Ã
expect ÆÐÅ°Áö°¡ ÀÖ´Ù´Â Á¶°Ç¿¡ ¾Æ·¡¿Í °°ÀÌ »ç¿ëÇÕ´Ï´Ù.
- [root@10-VM ~]# rpm -qa expect
expect-5.44.1.15-5.el6_4.x86_64
[root@10-VM ~]# ll /usr/bin/expect -rwxr-xr-x 1 root root 11304 Oct 31 2013 /usr/bin/expect
- ´ÜÀÏ ¼¹ö ÀÛ¾÷½Ã
#vim reboot.exp
#!/usr/bin/expect spawn bash -c "ssh root@10.10.10.11" expect -re "password" send "Æнº¿öµå\r" expect -re "#" send "reboot\r" interact
- ½ºÅ©¸³Æ® ½ÇÇà ¹æ¹ý
expect -f reboot.exp
- ´ÙÁß ¼¹ö ÀÛ¾÷½Ã
/root/HOST ¾È¿¡ ¼¹ö Á¤º¸µé (IP) µîÀ» ¹Ì¸® ³Ö¾îµÓ´Ï´Ù.
- vim reboot.sh
#!/bin/bash for HOST in `cat /root/HOST` do expect <<EOF sleep 0.5 spawn bash -c "ssh root@$HOST" expect -re "password" send "Æнº¿öµå\r" expect -re "#" - send "reboot\r"
- interact
- EOF
- done
- ½ÇÇà¹æ¹ý
#sh reboot.sh
|
|
|