🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #3979

Re: Displaying output from STDOUT/STDERR from tcsh shell on a web browser

#3979
From: David Hassett
Date: Wed, 31 May 2000 00:00
48 lines
2062 bytes
Miles Davenport wrote:
> 
> I am in the process of writing a tcsh script which will be called from a
> browser via a submit form button.  I want to know how to to redirect all
> outputs such as STDOUT/ERR to the browser so the user can see whats
> happening.
> 
> I remember something like &2>1 in Perl, but can't remember how to do it.
> 
> Can anyone help.

PLEASE don't use csh (even tcsh) for scripting something as important as
a CGI script. See:

http://language.perl.com/versus/csh.whynot


for some reasons. Use a Bourne derivative (bash, ksh, sh, zsh, etc...)
for scripting even if you prefer to use tcsh for interactive sessions.

Now...

You can redirect standard output to standard error by:

"1>&2" or more simply ">&2"

e.g. echo "This is an error" >&2

You can redirect standard error to standard output by (the opposite of
the above):

"2>&1"

e.g. ls foo_bar_and_such_things 2>&1

will redirect the error message "ls: foo_bar_and_such_things: No such
file or directory" to standard output rather than standard error.

I assume that for a web page, everything will want to go to standard
output, so the latter construct is what you require (note that that is
impossible to do in csh!).

I hope this helps, and if you require answers to more specific
questions, please post them. :-)

Cheers,

Dave. :-)
Technical Details
Message-ID: <39355ED3.54D64977@ncl.ac.uk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <959786175.7562.0.nnrp-06.d4e4dc01@news.demon.co.uk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1012a6,64ad3c72177ca6a5
X-Google-Attributes: gid1012a6,public
X-Google-Thread: 109f25,64ad3c72177ca6a5
X-Google-Attributes: gid109f25,public
From: David Hassett <d.j.hassett@ncl.ac.uk>
Subject: Re: Displaying output from STDOUT/STDERR from tcsh shell on a web  browser
Date: 2000/05/31
Message-ID: <39355ED3.54D64977@ncl.ac.uk>
X-Deja-AN: 629543712
Content-Transfer-Encoding: 7bit
References: <959786175.7562.0.nnrp-06.d4e4dc01@news.demon.co.uk>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Organization: University of Newcastle-upon-Tyne
Mime-Version: 1.0
Newsgroups: comp.unix.shell,fj.unix.shells