I have been trying to come up with a way to grab the NTP IP address in /etc/ntp.conf and use it in a variable for one of my scripts. Basically, this would grab it and auto populate a reports file with all network-like info, of which the NTP address is an entry.

*Also, for the network that I am working on, it doesn't connect to the Internet, so it doesn't have the usual FQDN's for the 'server' line.

I know sed and awk can grab the entry after "server" in ntp.conf, but there are a lot of words throughout the file with "server", which wouldn't work for me.

So, I was thinking of adding a commented out phrase to the end of the actual line to search for, so it would narrow it down to a unique line in the file:

Code:

server 192.168.1.3 #NTP_IP

...then, somehow, grab just the IP.

Can someone help me out, using the above example "server" entry and trim off the word "server" and "#NTP_IP", along with the spaces between those words?

It properly echoes the correct IP from /etc/ntp.conf to the screen, but does not go in and change the TSVR placemarker in the net_reports.txt file.It gives this error:sed: -e expression #1, char 25: unterminated `s' command

Basically, this would grab it and auto populate a reports file with all network-like info, of which the NTP address is an entry.[...]So, I was thinking of adding a commented out phrase to the end of the actual line to search for, so it would narrow it down to a unique line in the file:

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum