linux 장비 원격 실행 프로그램

프로그래밍|2018. 5. 8. 17:02

It's my first time to write English article in this blog.


I am going to share my program that can be executed on several linux machine.


Long time ago, I wanted to execute for date command on the linux system that we manage.

I accessed a linux machine repeatedly.

It was difficult for me to do it.

So, I made a program blow.


cmd.sh

#!/bin/sh

if [ $# -lt 2 ]
then
    echo "Usage : $0 {명령어} {서버리스트파일}"
    exit 1
fi

servers=`cat $2`

for ip in $servers
do
    echo "-------------------------------------------------"
    echo "ssh ${ip} $1"
    echo "-------------------------------------------------"
    ssh ${ip} "$1"
    echo "\n"
done

servers 파일

nklee@172.19.136.18
nklee@172.19.136.18
nklee@172.19.136.18


This program is simple and easy to use.

You can use following UNIX command.

1
$ ./cmd.sh hostname servers
cs

Thank you for reading this article.

댓글()