Subject: | |
From: | |
Reply To: | |
Date: | Fri, 17 Jan 1997 15:47:35 -0800 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Chris Breemer wrote:
>
> Hi All,
>
> Does anybody know if/how I can redirect output to a terminal window
> under the shell ?
>
> Under HP-UX, I use tty(1) in a particular window to find out what the
> psuedo device name is, and use that as a filename. Great for displaying
> logfiles on the screen as you go.
> But on MPE there does not seem such a thing as a device name for a terminal
> window; the tty(1) command returns a ldev but not the name of a device file.
>
> Any suggestions most welcome !
> TIA
> --
>
> :)
> Chris Breemer [log in to unmask]
> COMPUWARE EUROPE B.V.
____________________________________________________________________________________________________________
I have delayed sending this, thinking that surely some Posix guru out
there had a simple, straightforward answer to your question. Since I
haven't seen one, I'll offer this:
The following "quick and dirty" test script uses two functions to
emulate
the echo and cat commands. If you are writing to the terminal on an MPE
system, they use CI commands; otherwise they use the shell commands.
-------------------------------------------------------------------------
#!/bin/sh
#
#####
# Syntax : Echo "string" file
Echo() {
if [ $2 = `tty` ] && [ `uname -s` = "MPE/iX" ] #if tty and MPE
system
then #then
callci "ECHO $1>\$STDLIST" # CI ECHO to
$STDLIST
else #else
echo $1>>$2 # shell echo
fi;
}
#####
# Syntax : Cat infile outfile
Cat() {
if [ $2 = `tty` ] && [ `uname -s` = "MPE/iX" ] #if tty and MPE
system
then #then
if [ $1 = `basename $1` ] # if no Posix
path
then # then
callci "PRINT ./$1>\$STDLIST" # CI PRINT, add
path
else # else
callci "PRINT $1>\$STDLIST" # CI PRINT
fi
else #else
cat $1>>$2 # shell cat
fi;
}
#####
# This will Echo to the terminal
LOGFILE=`tty`
Echo "Hello World from Echo" $LOGFILE
#####
# This will Echo to logtest, then Cat logtest to the terminal
LOGFILE="logtest"
Echo "Hello World from Cat" $LOGFILE
Cat $LOGFILE `tty`
#####
# This will Cat logtest to logtest2
Cat $LOGFILE logtest2
-------------------------------------------------------------------------
I have executed this script in both MPE (5.0) Posix and HP-UX (10.01),
and it is portable between the two with no modifications.
Although this works, I keeping thinking that there must be a simpler
answer. If someone shared one with you privately, I'd appreciate your
letting us in on the secret.
Also, if it turns out you can actually use this, I'll be glad to answer
any questions you may have.
--Ken Kirby
Vanderbilt University
|
|
|