Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Suppress output from a command line tool

Reply
 
Old 05-18-2007   #1 (permalink)
Chris Harris


 
 

Suppress output from a command line tool

I'm writing a script that wraps nslookup to gather DNS information from
multiple servers so I can confirm that they are in agreement.

Unfortunately, when nslookup runs it always returns the following error for
each lookup that I can't seem to suppress.

*** Can't find server name for address 204.74.113.1: No information

How can I get rid of this?

Here's a sample NSLookup command that I'm running:

nslookup blackbaud.com 204.74.112.1

If you run it, you can see there is plenty of other output, but only the
error message is displayed when executed in a script.

thanks for the help!

-Chris

My System SpecsSystem Spec
Old 05-18-2007   #2 (permalink)
RichS


 
 

RE: Suppress output from a command line tool

have to tried piping the output to a file and then parsing the file

--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"Chris Harris" wrote:

> I'm writing a script that wraps nslookup to gather DNS information from
> multiple servers so I can confirm that they are in agreement.
>
> Unfortunately, when nslookup runs it always returns the following error for
> each lookup that I can't seem to suppress.
>
> *** Can't find server name for address 204.74.113.1: No information
>
> How can I get rid of this?
>
> Here's a sample NSLookup command that I'm running:
>
> nslookup blackbaud.com 204.74.112.1
>
> If you run it, you can see there is plenty of other output, but only the
> error message is displayed when executed in a script.
>
> thanks for the help!
>
> -Chris

My System SpecsSystem Spec
Old 05-18-2007   #3 (permalink)
Marco Shaw


 
 

Re: Suppress output from a command line tool

Chris Harris wrote:
> I'm writing a script that wraps nslookup to gather DNS information from
> multiple servers so I can confirm that they are in agreement.
>
> Unfortunately, when nslookup runs it always returns the following error for
> each lookup that I can't seem to suppress.
>
> *** Can't find server name for address 204.74.113.1: No information
>
> How can I get rid of this?
>
> Here's a sample NSLookup command that I'm running:
>
> nslookup blackbaud.com 204.74.112.1
>
> If you run it, you can see there is plenty of other output, but only the
> error message is displayed when executed in a script.
>
> thanks for the help!
>
> -Chris


I'm struggling to determine exactly what you're looking to do.

If you try this:
91# $lookup=nslookup blackbaud.com 204.74.112.1
*** Can't find server name for address 204.74.112.1: No information

Then $lookup won't have that "No information" line, and use can use what
$lookup contains for whatever you're trying to do?

Marco
My System SpecsSystem Spec
Old 05-18-2007   #4 (permalink)
Chris Harris


 
 

Re: Suppress output from a command line tool

Thanks, Marco

I am using a variable to hold the results (and the variable doesn't contain
the error), but even when I do that the error message is displayed as in your
example below.

Thanks,
chris

"Marco Shaw" wrote:

> Chris Harris wrote:
> > I'm writing a script that wraps nslookup to gather DNS information from
> > multiple servers so I can confirm that they are in agreement.
> >
> > Unfortunately, when nslookup runs it always returns the following error for
> > each lookup that I can't seem to suppress.
> >
> > *** Can't find server name for address 204.74.113.1: No information
> >
> > How can I get rid of this?
> >
> > Here's a sample NSLookup command that I'm running:
> >
> > nslookup blackbaud.com 204.74.112.1
> >
> > If you run it, you can see there is plenty of other output, but only the
> > error message is displayed when executed in a script.
> >
> > thanks for the help!
> >
> > -Chris

>
> I'm struggling to determine exactly what you're looking to do.
>
> If you try this:
> 91# $lookup=nslookup blackbaud.com 204.74.112.1
> *** Can't find server name for address 204.74.112.1: No information
>
> Then $lookup won't have that "No information" line, and use can use what
> $lookup contains for whatever you're trying to do?
>
> Marco
>

My System SpecsSystem Spec
Old 05-18-2007   #5 (permalink)
Keith Hill


 
 

Re: Suppress output from a command line tool

"Chris Harris" <Chris Harris@discussions.microsoft.com> wrote in message
news:3391ADF9-59E6-45D4-88A6-1C052C97C734@microsoft.com...
> I'm writing a script that wraps nslookup to gather DNS information from
> multiple servers so I can confirm that they are in agreement.
>
> Unfortunately, when nslookup runs it always returns the following error
> for
> each lookup that I can't seem to suppress.
>
> *** Can't find server name for address 204.74.113.1: No information
>
> How can I get rid of this?
>
> Here's a sample NSLookup command that I'm running:
>
> nslookup blackbaud.com 204.74.112.1
>
> If you run it, you can see there is plenty of other output, but only the
> error message is displayed when executed in a script.


nslookup blackbaud.com 204.74.112.1 2>$null

will redirect the error stream output to $null i.e. will cause it to not be
displayed.

--
Keith

My System SpecsSystem Spec
Old 05-23-2007   #6 (permalink)
Chris Harris


 
 

Re: Suppress output from a command line tool

Hi Keith,
Redirecting to $null didn't seem to work as I still see the error message
and my $result variableis null as well

PS C:\Toolbox\Scripts\DNSCheck> $result = nslookup notices.dfwworld.org
i.root-s
ervers.net >$null
*** Can't find server name for address 192.36.148.17: No information
PS C:\Toolbox\Scripts\DNSCheck> $result
PS C:\Toolbox\Scripts\DNSCheck>

This has really got me stumped!

-Chris


"Keith Hill" wrote:

> "Chris Harris" <Chris Harris@discussions.microsoft.com> wrote in message
> news:3391ADF9-59E6-45D4-88A6-1C052C97C734@microsoft.com...
> > I'm writing a script that wraps nslookup to gather DNS information from
> > multiple servers so I can confirm that they are in agreement.
> >
> > Unfortunately, when nslookup runs it always returns the following error
> > for
> > each lookup that I can't seem to suppress.
> >
> > *** Can't find server name for address 204.74.113.1: No information
> >
> > How can I get rid of this?
> >
> > Here's a sample NSLookup command that I'm running:
> >
> > nslookup blackbaud.com 204.74.112.1
> >
> > If you run it, you can see there is plenty of other output, but only the
> > error message is displayed when executed in a script.

>
> nslookup blackbaud.com 204.74.112.1 2>$null
>
> will redirect the error stream output to $null i.e. will cause it to not be
> displayed.
>
> --
> Keith
>

My System SpecsSystem Spec
Old 05-23-2007   #7 (permalink)
Keith Hill


 
 

Re: Suppress output from a command line tool

"Chris Harris" <ChrisHarris@discussions.microsoft.com> wrote in message
news:3A7382B9-A457-47EE-86A0-BC9FCA24C3D4@microsoft.com...
> Hi Keith,
> Redirecting to $null didn't seem to work as I still see the error message
> and my $result variableis null as well
>
> PS C:\Toolbox\Scripts\DNSCheck> $result = nslookup notices.dfwworld.org
> i.root-s
> ervers.net >$null
> *** Can't find server name for address 192.36.148.17: No information
> PS C:\Toolbox\Scripts\DNSCheck> $result
> PS C:\Toolbox\Scripts\DNSCheck>


You have to have a "2" in front of the redirect operator. It tells
PowerShell to redirect only the stderr stream to null. Try it this way:

$result = nslookup notices.dfwworld.org i.root-servers.net 2>$null

--
Keith

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
how to log output from a command line program VB Script
Re: Send command line via WMI - Pipe output to text file on remote PowerShell
BitLocker Command Line Tool? Vista security
Wmic command-line tool in Vista 64 Vista General
Output Event Log From Command Line Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46