Hey I'm new to scripting and I wanted to create a bash script that would first ping all the nodes at my work and then try to ssh into all the nodes and list if the commands were successful or not into a file which then gets emailed to me and other important people at work. This is what I have so far;
#!/bin/bash
####################
# Config
####################
# Client Host list
nodes=`cat host_list`
date= `date`
for node in ${nodes}; do
echo -n "Attempting to reach $node..."
ping -c 3 $node > /dev/null
if [ $? -ne 0 ]; then
echo "$node not alive" >> /home/alex/node_status$date.txt
else
# do ssh here
echo "$node on-line" >> /home/alex/node_status$date.txt
fi
done
Thanks in advanced for any suggestions.
Alex
#!/bin/bash
####################
# Config
####################
# Client Host list
nodes=`cat host_list`
date= `date`
for node in ${nodes}; do
echo -n "Attempting to reach $node..."
ping -c 3 $node > /dev/null
if [ $? -ne 0 ]; then
echo "$node not alive" >> /home/alex/node_status$date.txt
else
# do ssh here
echo "$node on-line" >> /home/alex/node_status$date.txt
fi
done
Thanks in advanced for any suggestions.
Alex