[Seattle-SAGE] Redirect stderr and stdout?

Atom Powers atom.powers at gmail.com
Mon Feb 6 16:45:47 PST 2006

I ended wrapping it a shell like so:  (also gives me only the last two
lines without line breaks, for Nagios)

/usr/bin/time -h /bin/sh -c "exec $SMBCLIENT -N -L $samba_host
>/dev/null" 2>&1 | tail -n2 | tr -d "\n"
exit $?

It redirects the output of smbclient to /dev/null; *then* redirects
stderr to stdout where I can process it.

On 2/6/06, Kurt Buff <kurt.buff at gmail.com> wrote:
> Atom Powers wrote:
> > I'm trying to write a script that tests how long it takes to list the
> > shares on a samba server and prints the result to stdout. But I don't
> > want a list of all the shares, which smbclient normally sends to
> > stdout.
> >
> > So far I have:
> > $ /usr/bin/time -h `which smbclient` -N -L ${server} 1> /dev/null
> >
> > Problem is: the time outuput goes into stderr and I need it to go to
> > stdout; if I "2>1" then it goes into /dev/null. Smbclient outputs a
> > lot of data to stdout that I don't want (the list of shares).
> >
> > Any ideas?
> $ date && /usr/bin/time -h `which smbclient` -N -L ${server} 1>
> /dev/null && date
> Kurt

Perfection is just a word I use occasionally with mustard.
--Atom Powers--

More information about the Members mailing list