- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Output redirection help in ksh script
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
Discussions
Discussions
Forums
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
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
тАО04-25-2006 03:32 AM
тАО04-25-2006 03:32 AM
{ fbackup $backup_type -u $verbose_option $nfs_option -g $graph_file $index_opt
} $logfile 1> $logfile
Here is what it looked like when it ran using (ksh -x scriptname )
+ 0< /bow/resp + fbackup -0 -u -n -g /bow/bowgraph -I /bow/backuplogs/25Apr06.full -c /bow/backup_config -d /bow/fbackupfiles/datesm (*output cut off*)
fbackup(1004): session begins on Tue Apr 25 11:01:25 2006
fbackup(3203): volume 1 has been used 7 time(s)
fbackup(3024): writing volume 1 to the output file /dev/rmt/0m
fbackup(3009): WARNING: File number 72630 (/orabackup/oradata/ediprod/redologs/ediprod_redo2.dbf)
was not successfully backed up
fbackup(3055): total file blocks read for backup: 25546882
fbackup(3056): total blocks written to output file /dev/rmt/0m: 26110005
fbackup(1030): warnings encountered during backup
I wanted the above output to go into the file pointed to by $logfile. I pointed standard output and stantard error to $logfile which was empty after the job ran. $logfile and all other variables in the above line are defined earlier in the script.
Any suggestions?
Solved! Go to Solution.
- Tags:
- redirect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2006 03:37 AM
тАО04-25-2006 03:37 AM
Re: Output redirection help in ksh script
} &1 1> $logfile
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2006 04:23 AM
тАО04-25-2006 04:23 AM
Re: Output redirection help in ksh script
you are using different redirections to the same file - which one will win?
Configure the output an error stream instead:
1) use different files for stdout and stderr
{
cmd
} >outfile 2>errorfile
2) Redirect one stream to the other
{
cmd
} >outfile 2>&1
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2006 04:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2006 04:53 AM
тАО04-25-2006 04:53 AM
Re: Output redirection help in ksh script
Order is important here, too!
Run this script snippet:
# cat .redir
#!/usr/bin/sh
echo "from stdout"
print -u2 "from stderr"
exit 0
...Do this:
# ./redir 2>&1 1> /redir.log
from stderr
# cat redir.log
from stdout
Now:
# ./redir 1> /redir.log 2>&1
# cat redir.log
from stdout
from stderr
In the second case you achieve what you want. In the first case, STDERR was assigned to your terminal *and* then STDOUT was assigned to the file.
Regards!
...JRF...
#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2006 05:12 AM
тАО04-25-2006 05:12 AM
Re: Output redirection help in ksh script
Actual code:
{ fbackup $backup_type -u $verbose_option $nfs_option -g $graph_file $index_opt
} &1 1>$logfile
Actual output
+ 0< /bow/resp 2>& 1 + fbackup -0 -u -n -g /bow/bowgraph -I /bow/backuplogs/25Apr06.full -c /bow/backup_config -d /bow/fbackupfilesm
fbackup(1004): session begins on Tue Apr 25 13:04:09 2006
fbackup(3203): volume 1 has been used 8 time(s)
fbackup(3024): writing volume 1 to the output file /dev/rmt/0m
fbackup(3055): total file blocks read for backup: 25676534
fbackup(3056): total blocks written to output file /dev/rmt/0m: 26241878
The output file is completely empty. Did I miss something?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2006 05:16 AM
тАО04-25-2006 05:16 AM
Re: Output redirection help in ksh script
>$logfile 2>&1
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2006 05:17 AM
тАО04-25-2006 05:17 AM
Re: Output redirection help in ksh script
With regard to your second question, see my post just above: "Order is important here, too!"
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2006 05:24 AM
тАО04-25-2006 05:24 AM
Re: Output redirection help in ksh script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2006 07:13 AM
тАО04-25-2006 07:13 AM
Re: Output redirection help in ksh script
{ fbackup $backup_type -u $verbose_option $nfs_option -g $graph_file $index_option -c $config_file -d $fbackupfiles -f $device
} $logfile 2>&1
fbackup(1004): session begins on Tue Apr 25 15:02:37 2006
fbackup(3203): volume 1 has been used 9 time(s)
fbackup(3024): writing volume 1 to the output file /dev/rmt/0m
fbackup(3055): total file blocks read for backup: 21220083
fbackup(3056): total blocks written to output file /dev/rmt/0m: 21787601
Still no output in the file. I will now try the method given by Rodney.