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
 
ldns-walk(1)						      General Commands Manual						      ldns-walk(1)

NAME
ldns-walk - Retrieve the contents of a DNSSEC signed zone SYNOPSIS
ldns-walk [ OPTION ] ZONE DESCRIPTION
ldns-walk is used to retrieve the contents of a DNSSEC signed zone. It does this through NSEC-walking (following the chain of NSEC records) and 'guessing' the next non-existent owner name for each NSEC. Note that it might get stuck on some wildcard records when used through a caching forwarder. This problem can be circumvented by querying the authoritative nameserver directly (with the @ argument). Of course the nameserver that is used must be DNSSEC-aware. OPTIONS
-f Do a 'full' zone walk; by default, ldns-walk will only show the names, and types present at those names. If this option is given, all resource records will be printed. -s name Start the walk with this owner name. Useful when continuing the walk for a large zone. @ nameserver Send the queries to this nameserver. BUGS
The full zone walk function is not complete yet, it does not correctly print delegation records AUTHOR
Written by Jelte Jansen as an example for ldns usage. REPORTING BUGS
Report bugs to <ldns-team@nlnetlabs.nl>. COPYRIGHT
Copyright (C) 2005 NLnet Labs. This is free software. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR- POSE. 21 Nov 2005 ldns-walk(1)
All times are GMT -4. The time now is 01:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy