[Gllug] This morning's shell script question

Alain Williams addw at phcomp.co.uk
Thu May 24 08:05:02 UTC 2007


On Thu, May 24, 2007 at 08:49:04AM +0100, Richard Jones wrote:
> 
> From a shell script I want to run a command and sends the command's
> stderr to a pipe (to the logger command, in fact).  But leave
> stdin/stdout connected to the terminal as normal.
> 
> How do I do that?

The following works with ksh:
	exec 3>&1
	od -c > x |&
	exec 1>&p 2>&3
	date
	w >&2

(date writes to stdout - which goes to od -c and thence to the file x,
 w write to stderr which goes to the terminal)

-- 
Alain Williams
Linux Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
#include <std_disclaimer.h>
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list