Is there a way to differentiate between the output resulting from an error
generated by a command and the successful completion of a command (both
normally written to the terminal) I've heard about sterr and stout and
think they are both written to the terminal.
The command (dig) that I want to use in a script could:
1 successfully return results
2 successfully fail to return results because no results are available
3 fail altogether due to network problems / unavailability of remote servers
etc
I presume 1 + 2 are stout and 3 is sterr - can BASH pickup this
difference?
Thanks,
Edward.
Background:
I'm planing a script that will use the dig command to check where a domain
name is delegated to.
for $domain from a list of domains, I'll run the command:
dig $domain NS. (checks what DNS servers a domain is delegated to)
If the command fails (sterr) I'll write the domain to a failure file
If the command runs successfully, I'll grep the output for our DNS servers
and, if found, write $domain to a file localDNS.
If our DNS servers are not found in the grep I'll write $domain to a file
remoteDNS.
For a domains in remoteDNS, I'll establish the actual DNS server from the
output of the dig command and specify it as a variable $dnsserver.
$dnsserver will be used in further DNS commands of the form:
the results will be written to the remoteDNS file.
etc etc