- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: saving out put to file - a better way ??
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
01-03-2001 12:07 PM
01-03-2001 12:07 PM
Is there a better way to do this then using
>> on everyline ?
------------------
echo "HP9000" >> daily.txt
remsh boxname -l root "tail -n30 /var/adm/syslog/syslog.log" >> daily.txt
----------------
Solved! Go to Solution.
- Tags:
- redirect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2001 12:24 PM
01-03-2001 12:24 PM
SolutionYes, duplicate the stdout descriptor. Try this:
#!/usr/bin/sh
exec >&1 >> /tmp/output
echo "It's $(date)"
Notice that all your output goes to the file /tmp/output without the need to redirect it as you go.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2001 12:29 PM
01-03-2001 12:29 PM
Re: saving out put to file - a better way ??
sub shell grouping:
(
your stuff
) >> file.out
your code will run in a sub shell environment which means there will be no side effects, ie if you change variables in the grouping once your out of the grouping your changes won't be there. If you do nesting you'll need to put white space between the parentheses to avoid arithmetic evaluation.
you can also do a brace grouping:
{
your stuff
} >> file.out
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2001 12:30 PM
01-03-2001 12:30 PM
Re: saving out put to file - a better way ??
Another way to do it is to specify the output file when you run the script, like so:
./myscript >> daily.txt
Just a thought,
Mo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2001 09:52 PM
01-03-2001 09:52 PM
Re: saving out put to file - a better way ??
James definitely showed you the way to go.
Nevertheless, in his example, standard error will not be redirected to the file as '>&1' comes before '>>'.
If you want both standard error and standard output to be redirected you could use the following constructs:
exec > /tmp/output 2>&1 # to redirect both in same file
exec > /tmp/output 2>/tmp/error # to redirect in different files
Best regards,
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2001 11:23 AM
01-04-2001 11:23 AM
Re: saving out put to file - a better way ??
Within the KSH you can write the output to a running program. Use "exec >&p". I use it in my spooler print drivers to write to jetdirect connected printers.
/opt/hpnp/hpnpf -x 192.16.0.10 |&
exec >&p
From then on, all stdout from the script will go to the stdin of program hpnpf.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2001 11:34 AM
01-04-2001 11:34 AM
Re: saving out put to file - a better way ??
| tee -a /usr/tmp/filename