Loop over multiple addresses: ping and drop data into file
I would like to be able to have a script that will:
look at a list of IP addresses
Ping one of the addresses
Take the data and drop it in to a file
Move on to the next IP
So far I have:
cd /Path/to/addressees || exit 1
for targethost in a b c; do
{ping {targethost}
echo $'\n'"finished:
} >"$log_file" 2>&1
done
When I run this I receive the errors:
./ping_address: line 3: cd: /path/to/ip_adress: No such file or directory
./ping_address: line 7: unexpected EOF while looking for matching `"'
./ping_address: line 8: syntax error: unexpected end of file
I am still a little new to scripting on Unix so any help would be really helpful!
I would like to be able to have a script that will:
look at a list of IP addresses
Ping one of the addresses
Take the data and drop it in to a file
Move on to the next IP
So far I have:
cd /Path/to/addressees || exit 1
for targethost in a b c; do
{ping {targethost}
echo $'\n'"finished:
} >"$log_file" 2>&1
done
When I run this I receive the errors:
./ping_address: line 3: cd: /path/to/ip_adress: No such file or directory
./ping_address: line 7: unexpected EOF while looking for matching `"'
./ping_address: line 8: syntax error: unexpected end of file
I am still a little new to scripting on Unix so any help would be really helpful!
No comments:
Post a Comment