The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
if a file is empty throw an error mavesum UNIX for Dummies Questions & Answers 4 12-08-2008 11:02 AM
help for /Input/outpur error s123.radha UNIX for Dummies Questions & Answers 3 07-29-2008 04:32 AM
nawk empty regular expression error Rjkz Shell Programming and Scripting 6 12-21-2007 11:07 AM
Syntax error at the end of input naan High Level Programming 2 12-11-2007 02:09 AM
Suppres error message when moving files from empty source folder Steven Shell Programming and Scripting 2 11-19-2001 01:25 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-31-2009
mohitmoudgil mohitmoudgil is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 12
Unhappy Script error with when input is empty

Hi,

I created the following shell script to lookup multiple name servers for a domain.


Code:
#!/bin/bash

echo -n "Enter the domain name and press [ENTER]: "
read domain


result1=`dig +short $domain @4.2.2.1`
revresult1=`host $result1 | cut -f5 -d " "`

echo "test1"

result2=`dig +short $domain @dns1.vistapages.com`
revresult2=`host $result2 | cut -f5 -d " "`

echo "test2"

result3=`dig +short $domain @dns2.vistapages.com`
revresult3=`host $result3 | cut -f5 -d " "`



echo "test3"
result4=`dig +short $domain @ns1.hostmds.com`
revresult4=`host $result4 | cut -f5 -d " "`

echo "test4"
result5=`dig +short $domain @ns1.hostmds.com`
revresult5=`host $result5 | cut -f5 -d " "`

echo "test5"
result6=`dig +short $domain @dns1.hostingplex.com`
revresult6=`host $result6`

echo "test6"
result7=`dig +short $domain @dns2.hostingplex.com`
revresult7=`host $result7`

echo "test7"
echo "================================="

echo " Result at Verizon DNS : $result1"
echo " Reverse at Verizon DNS : $revresult1"

echo "================================="
echo " Result at dns1.vistapages.com  : $result2"
echo " Reverse at dns1.vistapages.com : $revresult2"
echo "================================="

echo " Result at dns2.vistapages.com : $result3"
echo " Reverse at dns2.vistapages.com : $revresult3"

echo "================================="

echo " Result at ns1.hostmds.com : $result4"
echo " Reverse at ns1.hostmds.com : $revresult4"

echo "================================="
echo " Result at ns2.hostmds.com : $result5"
echo " Reverse at ns2.hostmds.com : $revresult5"

echo "================================="

echo " Result at dns1.hostingplex.com : $result6"
echo " Reverse at dns1.hostingplex.com  : $revresult6"
echo "================================="


echo " Result at dns2.hostingplex.com : $result7"
echo " Reverse at dns2.hostingplex.com : $revresult1"

But when the dns server do not have any result the script generates error.


Code:
Enter the domain name and press [ENTER]: test.com
test1
Usage: host [-aCdlriTwv] [-c class] [-N ndots] [-t type] [-W time]
            [-R number] hostname [server]
       -a is equivalent to -v -t *
       -c specifies query class for non-IN data
       -C compares SOA records on authoritative nameservers
       -d is equivalent to -v
       -l lists all hosts in a domain, using AXFR
       -i IP6.INT reverse lookups
       -N changes the number of dots allowed before root lookup is done
       -r disables recursive processing
       -R specifies number of retries for UDP packets
       -t specifies the query type
       -T enables TCP/IP mode
       -v enables verbose output
       -w specifies to wait forever for a reply
       -W specifies how long to wait for a reply
       -4 use IPv4 query transport only
       -6 use IPv6 query transport only
       -s a SERVFAIL response should stop query
test2
Usage: host [-aCdlriTwv] [-c class] [-N ndots] [-t type] [-W time]
            [-R number] hostname [server]
       -a is equivalent to -v -t *
       -c specifies query class for non-IN data
       -C compares SOA records on authoritative nameservers
       -d is equivalent to -v
       -l lists all hosts in a domain, using AXFR
       -i IP6.INT reverse lookups
       -N changes the number of dots allowed before root lookup is done
       -r disables recursive processing
       -R specifies number of retries for UDP packets
       -t specifies the query type
       -T enables TCP/IP mode
       -v enables verbose output
       -w specifies to wait forever for a reply
       -W specifies how long to wait for a reply
       -4 use IPv4 query transport only
       -6 use IPv6 query transport only
       -s a SERVFAIL response should stop query
test3
Usage: host [-aCdlriTwv] [-c class] [-N ndots] [-t type] [-W time]
            [-R number] hostname [server]
       -a is equivalent to -v -t *
       -c specifies query class for non-IN data
       -C compares SOA records on authoritative nameservers
       -d is equivalent to -v
       -l lists all hosts in a domain, using AXFR
       -i IP6.INT reverse lookups
       -N changes the number of dots allowed before root lookup is done
       -r disables recursive processing
       -R specifies number of retries for UDP packets
       -t specifies the query type
       -T enables TCP/IP mode
       -v enables verbose output
       -w specifies to wait forever for a reply
       -W specifies how long to wait for a reply
       -4 use IPv4 query transport only
       -6 use IPv6 query transport only
       -s a SERVFAIL response should stop query
test4
Usage: host [-aCdlriTwv] [-c class] [-N ndots] [-t type] [-W time]
            [-R number] hostname [server]
       -a is equivalent to -v -t *
       -c specifies query class for non-IN data
       -C compares SOA records on authoritative nameservers
       -d is equivalent to -v
       -l lists all hosts in a domain, using AXFR
       -i IP6.INT reverse lookups
       -N changes the number of dots allowed before root lookup is done
       -r disables recursive processing
       -R specifies number of retries for UDP packets
       -t specifies the query type
       -T enables TCP/IP mode
       -v enables verbose output
       -w specifies to wait forever for a reply
       -W specifies how long to wait for a reply
       -4 use IPv4 query transport only
       -6 use IPv6 query transport only
       -s a SERVFAIL response should stop query
test5
test6
test7
=================================
 Result at Verizon DNS : 205.178.152.103
 Reverse at Verizon DNS : w2k3-cfm3.prod.netsolhost.com.
=================================
 Result at dns1.vistapages.com  : 
 Reverse at dns1.vistapages.com : 
=================================
 Result at dns2.vistapages.com : 
 Reverse at dns2.vistapages.com : 
=================================
 Result at ns1.hostmds.com : 
 Reverse at ns1.hostmds.com : 
=================================
 Result at ns2.hostmds.com : 
 Reverse at ns2.hostmds.com : 
=================================
 Result at dns1.hostingplex.com : 208.83.209.12
 Reverse at dns1.hostingplex.com  : 12.209.83.208.in-addr.arpa domain name pointer 208-83-209-12.mdswireless.com.
=================================
 Result at dns2.hostingplex.com : 208.83.209.12
 Reverse at dns2.hostingplex.com : w2k3-cfm3.prod.netsolhost.com.

How can I get rid of these errors.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:39 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0