Hi,
I have a text file which has a bunch of host names in it. It looks as follows:
Code:
host1.universitydomain.edu
host2.universitydomain.edu
host3.universitydomain.edu
host4.universitydomain.edu
.
.
.
I want to delete some directories from each of these nodes if they exist.
I can ssh to all of the nodes but the file contents change dynamically so I need to write a script that does this job automatically.
My script looks like:
Code:
cat nodes.txt | while read line;
do
echo "ssh $line rm -rf /tmp/hadoop-0.19.1 &"
ssh $line rm -rf /tmp/hadoop-0.19.1 &
done
but when I run this script I figure that it doesn't work, for some reason when I manually ssh to the nodes and check /tmp directory, I still see hadoop-0.19.1 under /tmp. I tried to remove the & from the end so it looks like:
Code:
cat nodes.txt | while read line;
do
echo "ssh $line rm -rf /tmp/hadoop-0.19.1"
ssh $line rm -rf /tmp/hadoop-0.19.1
done
but in this case my script only removed the directory from the first host in the list and skipped the rest without even printing the echo message.
I'd appreciate any help, thanks in advance.