- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- shell script question - redirect standard output
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2002 10:23 AM
12-03-2002 10:23 AM
I am having the following problem in redirecting message to stdout.
Senario 1:
Here is my script and it works fine if I logged as user A and run the script.
----------------------------
TTY=`tty`
. /oracle/utils/orasid rendb
echo test start > $TTY
(sqlplus /nolog <
host echo hai > $TTY
exit
EOF
) > $HOME/sqllog.log
echo test finish > $TTY
---------------------------
The output is
-------------
test start
hai
test finish
------------
Senario 2:
But it doesn't work if I logged on as user A then change user to ' su - B' because my terminal device (tty) is own by user A.
Output:
/bin/sh: /dev/ttyp2: Cannot create the specified file.
Then I have tried to use file descriptor
exec 5>&1
. /oracle/utils/orasid rendb
echo test start >&5
(sqlplus /nolog <
host echo hai >&5
exit
EOF
) > $HOME/sqllog.log
echo test finish >&5
Output:
test start
/bin/sh: /dev/ttyp2: Cannot create the specified file.
test finish.
With the above method and still having the problem to display message 'hai' in the sql block above.
The above script will be used in Senario 2. Does anyone know how to go about resolve the issue.
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2002 10:26 AM
12-03-2002 10:26 AM
Re: shell script question - redirect standard output
REmove the redirection to $TTY
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2002 10:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2002 10:28 AM
12-04-2002 10:28 AM
Re: shell script question - redirect standard output
Instead of using $TTY, redirect the output to /dev/tty.
Good luck.
Olav Kappert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2002 10:31 AM
12-04-2002 10:31 AM
Re: shell script question - redirect standard output
Thanks everyone for your feedback. I have changed my script to use /dev/tty.