Filtering Fake inputs

Hi
My script takes input for a hostname.

echo "enter hostname [abcd123.efgh.ijk.com]
read hostname

Now I would like to filter the fake inputs.My hostnames always follow same syntax ( abcd123.efgh.ijk.com).

Appreciate everyones suggestions on this..Thanks..

You could either:

  1. Try pinging the servername given and only proceed if it succeeds but then other machines on the network could be entered and accepted.

  2. Have a text file listing the hosts, one per line, run a:

cat -n hostfilelist

To present the hosts names with a number in front of each, then ask the user to select a host by entering the number and then do something like:

read NUMBER
SELECTEDSERVER=`cat -n hostfilelist | grep "^${NUMBER} " | awk '{ print $NF }'`

Mmmmmm...

we have a complex environment..servers come and go quite often..all i want to check is

For ex:
If the input is 23bck.demo.tes.com--it should be rejected
2s39.demo.test.com--it should be rejected..
and
If the input is abcd123.efgh.ijk.com--it should be accepted.

Just wanted to check the input is entered in proper format or not...Thanks Tony..

---------- Post updated at 05:08 PM ---------- Previous update was at 04:25 PM ----------

Bingo..It worked...I used "nslookup" instead of ping...Have to say thanks to Tony..for throwing some light on this one.. :slight_smile: