向着自动化运维再次前进一小步!!!
本着自动化运维的理想,提前解放双手,让系统按照提前部署的方案来执行操作步骤,以此学习到这样的一个小技巧
[[email protected] ~]# cat telnet.sh #!/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin OUTPUT=/tmp/outputfile TEMPFIFO=/tmp/fifofile FILE=/root/aaa/ touch $OUTPUT tail -f $OUTPUT & mknod $TEMPFIFO p exec 8<>$TEMPFIFO telnet 192.168.1.252 <&8 > $OUTPUT & sleep 1 echo "user" >> $TEMPFIFO sleep 1 echo "password" >> $TEMPFIFO sleep 1 echo "n" >> $TEMPFIFO sleep 1 echo "sys" >> $TEMPFIFO sleep 1 echo "dis ip routing" >> $TEMPFIFO sleep 1 echo "dis cu int vlan" >> $TEMPFIFO sleep 1 echo "quit" >> $TEMPFIFO sleep 1 echo "quit" >> $TEMPFIFO mv $OUTPUT $FILE rm -rf $OUTPUT $TEMPFIFO