Sponsored Content
Full Discussion: I need help with...<various>
Top Forums Shell Programming and Scripting I need help with...<various> Post 302228301 by era on Saturday 23rd of August 2008 08:47:04 PM
Old 08-23-2008
You can have as many commands as you like between the "do" and "done", and of course, they can be new loops with "do" and "done" in them. Not sure where you'd need that, though. You can simply modify the sed script to shuffle things around in a different order if that's how you like them.

Code:
sed "s/.*/IP for $host is & at $nameserver"

The "s/from/to/" command in sed will substitute the stuff in "from" with the stuff in "to" on each line. In this case we are replacing the IP address printed by dig with the longer string. & retrieves the "from" string into the "to" string. Dot star is the regular expression for "everything on this line" (dot means any character, star means any number of times).

Just to show an alternate way of doing it, here's a loop which prints the message piecemeal.

Code:
#!/bin/sh
host=$1
dig +short ns $host |
while read nameserver; do
  echo -n "IP for $host is "
  dig +short @$nameserver $host | tr '\n' ' '  # replace final newline with space
  echo "at $nameserver"
done

Or you can interpolate with backticks

Code:
  echo IP for $host is `dig +short @$nameserver $host` at $nameserver

Backticks AKA grave accents (ASCII 96) capture the output of one command so you can use it in the command line of another command. Notice that those are not regular single quotes. Copy/paste them if you can't find them on your keyboard.

Last edited by era; 08-23-2008 at 09:57 PM.. Reason: Show alternate way of coding it with echos to print the desired message
 
PDNS_CONTROL(8) 					      System Manager's Manual						   PDNS_CONTROL(8)

NAME
pdns_control - Control the pDNS nameserver SYNOPSIS
pdns_control [options] command DESCRIPTION
pdns_control is used to send commands to a running pDNS nameserver. OPTIONS
A summary of options is included below. --help Show summary of options. --chroot=... Where PowerDNS is chrooted --config-dir=... Location of configuration directory (pdns.conf) --config-name=... Name of this virtual configuration - will rename the binary image --remote-address=... Remote address to query --remote-port=... Remote port to query --secret=... Secret needed to connect to remote PowerDNS --socket-dir=... Where the controlsocket will live COMMANDS
ccounts Show the content of the cache notify <domain> Adds a domain to the notification list, causing PDNS to send out notifications to the nameservers of a domain. Can be used if a slave missed previous notifications or is generally hard of hearing. notify-host <domain> <host> Same as above but with operator specified IP address as destination, to be used if you know better than PowerDNS. cycle Restart the nameserver so it reloads its configuration. ping Check if the server is alive. purge [<record>] Purge entries from the packet cache. If the record name ends with a dollar ($) all entries that end with that name are removed. If no record is specified the entire cache is purged. rediscover Instructs backends that new domains may have appeared in the database, or, in the case of the Bind backend, in named.conf. retrieve <domain> Retrieve a slave domain from its master. Done nearly immediatly. set <variable> <value> Set the configuration parameter <variable> to <value>. Currently only the query-logging can be set. show <variable> Show a single statistic, as present in the output of the list command. quit Tell a running pdns_server to quit. status Show usage statistics. uptime Show the uptime of the running server. version Print the version of the running pdns daemon. FILES
<socket> Control socket used to communicate with pdns_server. SEE ALSO
pdns_server(8) PowerDNS December 2002 PDNS_CONTROL(8)
All times are GMT -4. The time now is 06:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy