- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- scripting
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
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
03-09-2004 04:13 AM
03-09-2004 04:13 AM
The script:
_______________________
#!/usr/bin/sh
echo "Try" 2>&1 >/tmp/log
_______________________
is aquivalnt of:
_______________________
#!/usr/bin/sh
exec 2>&1
exec 1>/tmp/log
echo "Try"
_______________________
How can I modify the next one to use "exec" too?
_______________________
#!/usr/bin/sh
echo "Try" 2>&1 | tee -a /tmp/log_tee >/tmp/log
_______________________
I want to avoid using "2>&1 | tee -a /tmp/log_tee >/tmp/log"
after every "echo" command!
Thanks,
Troy
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2004 04:37 AM
03-09-2004 04:37 AM
Solutionexample-
#!/usr/bin/sh
(
echo "start of my process"
./myprocess
echo "end of my process"
) | tee -a /tmp/log_tee >/tmp/log
Another method is to use the "script" command to log all output (and input).
example-
#!/usr/bin/sh
script /tmp/log_tee
echo "start of my process"
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2004 04:39 AM
03-09-2004 04:39 AM
Re: scripting
The simplest way would be to
tail -f /tmp/log
in a different window.
Regards,
Dave.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2004 04:39 AM
03-09-2004 04:39 AM
Re: scripting
TMAN="2>&1 | tee -a /tmp/log_tee >/tmp/log"
echo "stuff" $TMAN
If the code does the job, why are we messing with it?
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2004 04:45 AM
03-09-2004 04:45 AM
Re: scripting
you can bundle consequtive echos in a function.
func1()
{
echo "Start"
echo "doing something"
echo "finished"
}
func1 2>&1 | tee -a /tmp/log_tee
The other alternative would define
O=2>&1 | tee -a /tmp/log_tee >/tmp/log
echo "Try" $O
BTW, what's the use of two copies in two files?
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2004 04:52 AM
03-09-2004 04:52 AM
Re: scripting
tee -a /tmp/log_tee >/tmp/log |&
exec 1>&p
echo "try"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2004 05:51 AM
03-09-2004 05:51 AM
Re: scripting
All these work. Now it is up to me to choose a solution.
Steven: I have seen alot of ugly scripts in my live. They work, but it doesn't meen anything.
Michael: The real script does't use 2 log file. One of them is /dev/console
Curt: Your solution is interesting.
Thanks again,
Troy