I am trying to take input from a file and direct it into a bash script. This script is meant to be a foreach loop. I would like the script to process each item in the list one by one and direct the output to a file.
[root@uverse ~]# cat 1loop
#!/bin/bash
# this 2>&1 to redirect STDERR & STDOUT to file
LIST=$1
for i in "$LIST"; do
ping -c 2 "$LIST"; &> /root/error_mess
done
I have a file called ipaddresses with one ip per line.
This script works if I supply one ip after the script name upon execution, but not like this
#./1loop < ipaddresses