Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending a variable to the host file

Status
Not open for further replies.
Oct 22, 2004
26
Was wondering if I could send a variable keyed by a user to the /etc/host file. I know that you can do it in vi but can this be scripted ?

eg

echo key in a Printer and Path!

home-01 123.123.....

read path

then what?


 
Are you just trying to grep a printer name from /etc/hosts? If so, grep <printername> /etc/hosts will do it.

However, it sounds as if you have a more detailed requirement?
 
I was trying to be a little clever I was wanting to insert what has been key in to a log file

so

eg I put
home-1 123.123
read path and put that into log
ex command
I think its echo $path > /opt/bin/tst.log

 
You can append lines of data to a file with:
echo "$data" >> /path/to/file

But I would be very wary of appending information to the /etc/hosts file. Also note that on Solaris it is, by default, a Read Only file (even for root).

I hope that helps.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top