nicky s
asked on
script needed
HI i need a script,
to execute ls command to a list of servers, i can directly ssh to the destination servers without password from one of the server...
to execute ls command to a list of servers, i can directly ssh to the destination servers without password from one of the server...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
for your code (while loop), the server list need to be one hostname per line.
In "for SERVER in $(cat /path/servers.txt)"
It is ok to use cat since it run only one time. The server list file can be multiple hostname separated by blank space or "newline"
In "for SERVER in $(cat /path/servers.txt)"
It is ok to use cat since it run only one time. The server list file can be multiple hostname separated by blank space or "newline"
ok, thanks wesly :)
The 'for' loop is not strictly a UUOC.
A better example is
cat file | grep word
A better example is
cat file | grep word
ASKER
while read line
do
ssh ddd@server1 "echo "$line:`ls -l /app/$line/xyz.txt | awk '{print $5}'`""
done < apps.txt
do the following for X number of servers