I have file called myfile which has the text "myserver" in it. I need to have a command to ping "myserver". How would I do that?
I tried
when I type
at the terminal I get the output as
. How do I do something like a
?
thanks,
Nick
I have file called myfile which has the text "myserver" in it. I need to have a command to ping "myserver". How would I do that?
I tried
when I type
at the terminal I get the output as
. How do I do something like a
?
thanks,
Nick
One way (no eval needed):
cat myfile | while read server_name
do
ping "${server_name}"
done
If myserver is the only word in myfile
ping $(cat myfile)
myvar=$(< myfile)
ping $myvar
or:
ping "$(< myfile)"
Actually, myserver is not the only word. It is in a line called
So I used
ping $(cat myfile | grep "Server-Name" | cut -d'=' -f2)
thanks guys!!!
myvar=$(< myfile)
ping ${myvar#*=}