Thursday, December 12, 2013

Automating tasks over telnet.

Ok. So it is a Stone Age and no one knows what SSH is. Everybody is using telnet.

Let's automate a service restarting task.

Cool and easy as 1,2,3.

{ \
 sleep 2; \
 echo "root"; \
 sleep 2; \
 echo "password"; \
 sleep 2; \
 echo "ps ax | grep my_cool_service"; \
 sleep 2; \
 echo "OLD_SERVICE_PID=\`ps ax | grep my_cool_service | awk '{print \$1}'\` && kill \$OLD_SERVICE_PID"; \
 sleep 2; \
 echo "service my_cool_service start && ps ax |grep my_cool_service"; \
 sleep 4; \
 } | telnet 10.10.10.10

  

No comments:

Post a Comment