13

[Solved] For Loop with 2 commands? (hostname prob)

view full story
linux-howto

http://www.unix.com – Hi I would like to ssh into serveral servers, print the hostname and do an ls (of files in a certain directory), and add these details to a file. so i have this: Code: #!/usr/bin/bash for host in hostnames_here do ssh $host echo "$HOSTNAME"  ls /directory_location > ~/new_file_name.txt done it doesn't work for me, it lists the files but doesn't echo/print the hostname.......which i need to distinguish between servers. any help gladly received! :) (HowTos)