. This might be a particularly stupid question, but I am new to shell scripting. Sorry for that!
I am trying to use the pipeline (to pass the output of the first command to the second one as its input parameter).
cat filename.csv | nslookup
functions as I expected, calls nslookup for every line in the file. However, same thing doesn't work for dig
cat filename.csv | dig
says
; <<>> DiG 9.8.1-P1 <<>>
;; global options: +cmd
;; connection timed out; no servers could be reached
I appreciate any help. Thanks!
I'm not sure that dig
reads from stdin. Rather,
The -f option makes dig operate in batch mode by reading a list of lookup requests to process from the file filename. The file contains a number of queries, one per line. Each entry in the file should be organized in the same way they would be presented as queries to dig using the command-line interface.
(from the man page)
Note as an aside that your nslookup example qualifies for this award (!) and could be rewritten as
nslookup < filename.csv
to achieve the same.