Re: exec question

From: Bill Verzal (BVerzal@KOMATSUNA.COM)
Date: Thu Sep 25 2003 - 10:58:16 EDT


Thus far I have this:

#!/usr/bin/ksh
#
# Test exec statements
#
> file1
> file2
t=`tty`
echo "This is statement #1"
exec >file1 2>file2
echo "This is statement #2"
exec 1>$t
tput smso
echo "This is statement #3"
tput rmso

sapcws:/tmp >./exectest.ksh
This is statement #1
This is statement #3
sapcws:/tmp >more file1
This is statement #2
sapcws:/tmp >cat file2

It works, but seems weird.

BV
--------------------------------------------------------

Bill Verzal
AIX Administrator, Komatsu America
(847) 970-3726 - direct
(847) 970-4184 - fax

|---------+---------------------------->
| | Chris Gregors |
| | <Chris.Gregors@TE|
| | LUS.COM> |
| | Sent by: IBM AIX |
| | Discussion List |
| | <aix-l@Princeton.|
| | EDU> |
| | |
| | |
| | 09/25/2003 09:15 |
| | AM |
| | Please respond to|
| | IBM AIX |
| | Discussion List |
| | |
|---------+---------------------------->
>-------------------------------------------------------------------------------------------------------------------------------|
  | |
  | To: aix-l@Princeton.EDU |
  | cc: |
  | Subject: Re: exec question |
>-------------------------------------------------------------------------------------------------------------------------------|

How about running the exec as a sub-shell?

echo "got here"
( exec ls >logfile 2>erfile )
echo "now got here"

-----Original Message-----
From: Bill Verzal [mailto:BVerzal@KOMATSUNA.COM]
Sent: Thursday, September 25, 2003 8:02 AM
To: aix-l@Princeton.EDU
Subject: exec question

Probably a simple question, but I'm at a loss. Google has offered some
suggestions, but nothing helps.

I have a script that does an "exec 1>filename 2>fileerr".

After the task finishes, how do I re-open stdout and stderr again so I can
print stuff on the screen (such as end times and stuff) ?

Thanks, Bill.
--------------------------------------------------------

Bill Verzal
AIX Administrator, Komatsu America
(847) 970-3726 - direct
(847) 970-4184 - fax



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:17:14 EDT