I am new at scripting. I have a file that each line is the shortname for a server.
ie -
Server1
Server2
Server3
I want to read in that file, do a nslookup and print the FQDN to a file.
I added an echo statement to make sure my variable was being read and changing. But the nslookup returns nothing.
** code below should just display the FQDN, I took out the writing to a file for now.
#!/bin/ksh
#
# Variables
#
Ifile=/home/khowe/ServerNames.txt
OFile=/home/khowe/FullName.txt
#
while read name kaka
do
# nslookup ${name} |grep Name | awk {'print $2'} >> ${OFile}
echo ${name}
nslookup ${name} |grep Name
done < ${Ifile}
Please become accustomed to provide decent context info of your problem.
It is always helpful to support a request with system info like OS and shell, related environment (variables, options), preferred tools, adequate (representative) sample input and desired output data and the logics connecting the two, and, if existent, system (error) messages verbatim, to avoid ambiguities and keep people from guessing.
You seem to have difficulties with upper and lower case S . Are you sure the correct name is in the input file?
nslookup will return the literal string Name in its output, so the original command should be fine (although grep -o on Linux would just return the name, if found) - provided either that the input file does contain fully qualified hostnames or you have defined the appropriate search domain(s) (assuming the hosts you're looking up are yours *).
What's the contents of the actual input file and your /etc/resolv.conf? *