
Authoritative DNS Lookup
|
261
query_type=$( exec basename "${0}" )
# Get and query for each host.
for hostname in "$@" ; do
if [[ "${query_type}" == ptr ]] ; then
# A typical scripting trick: when a case can begin
# with a numeral, place a dummy character such as x in
# front because the case syntax expects an alphanumeric
# character.
case "x${hostname}y" in
( x[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*y )
hostname=$( echo "${hostname}" | inaddr )
;;
( * )
;;
esac
fi
# Execute the query.
dig +trace +noall +answer "${query_type}" "${hostname}" | \
egrep "^${hostname}"
done
exit
Sending Files Between Shell Sessions
You can use the script presented in this section to send a file, or a directory of files
(including all subdirectories), from one system to another using a shell session on
each system. The script works by creating an rsync daemon (rsync is discussed in
Chapter 11) in the foreground to send the specified file or directory. It displays a few
different forms of rsync commands that could be used to receive that file or directory.
This script does not need to exist on the receiving system, so it can even be used to
send a copy of itself. The rsync package, however, must be installed on both systems.
The sending system must have network access open for the port num-
ber it uses to accept incoming rsync connections. The port number is
chosen at random from the range 12288 through 28671. You can over- ...