Link to home
Start Free TrialLog in
Avatar of nicky s
nicky sFlag for United States of America

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...
Avatar of nicky s
nicky s
Flag of United States of America image

ASKER

The sample script looks like

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
ASKER CERTIFIED SOLUTION
Avatar of Tintin
Tintin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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"
ok, thanks wesly :)
Avatar of Tintin
Tintin

The 'for' loop is not strictly a UUOC.

A better example is

cat file | grep word