<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Output redirection help in ksh script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975419#M99273</link>
    <description>You can do as I suggested. But the error is you assign 2 before 1. Reverse them...&lt;BR /&gt; &lt;BR /&gt;&amp;gt;$logfile 2&amp;gt;&amp;amp;1&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
    <pubDate>Tue, 25 Apr 2006 12:16:06 GMT</pubDate>
    <dc:creator>Rodney Hills</dc:creator>
    <dc:date>2006-04-25T12:16:06Z</dc:date>
    <item>
      <title>Output redirection help in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975413#M99267</link>
      <description>I am running a backup script and I would like the output saved in a log file.  I would appreciate a little help.  Here is the actual backup line&lt;BR /&gt;&lt;BR /&gt;{ fbackup $backup_type -u $verbose_option $nfs_option -g $graph_file $index_opt &lt;BR /&gt;}  $logfile 1&amp;gt; $logfile &lt;BR /&gt;&lt;BR /&gt;Here is what it looked like when it ran using (ksh -x scriptname )&lt;BR /&gt;&lt;BR /&gt;+ 0&amp;lt; /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*)&lt;BR /&gt;fbackup(1004): session begins on Tue Apr 25 11:01:25 2006&lt;BR /&gt;fbackup(3203): volume 1 has been used 7 time(s)&lt;BR /&gt;fbackup(3024): writing volume 1 to the output file /dev/rmt/0m&lt;BR /&gt;fbackup(3009): WARNING: File number 72630 (/orabackup/oradata/ediprod/redologs/ediprod_redo2.dbf)&lt;BR /&gt;        was not successfully backed up&lt;BR /&gt;fbackup(3055): total file blocks read for backup: 25546882&lt;BR /&gt;fbackup(3056): total blocks written to output file /dev/rmt/0m: 26110005&lt;BR /&gt;fbackup(1030): warnings encountered during backup&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;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. &lt;BR /&gt;&lt;BR /&gt;Any suggestions?</description>
      <pubDate>Tue, 25 Apr 2006 10:32:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975413#M99267</guid>
      <dc:creator>Mike Smith_33</dc:creator>
      <dc:date>2006-04-25T10:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: Output redirection help in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975414#M99268</link>
      <description>{ fbackup $backup_type -u $verbose_option $nfs_option -g $graph_file $index_opt&lt;BR /&gt;} &amp;amp;1 1&amp;gt; $logfile&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry d brown jr</description>
      <pubDate>Tue, 25 Apr 2006 10:37:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975414#M99268</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2006-04-25T10:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: Output redirection help in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975415#M99269</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;you are using different redirections to the same file - which one will win?&lt;BR /&gt;&lt;BR /&gt;Configure the output an error stream instead:&lt;BR /&gt;&lt;BR /&gt;1) use different files for stdout and stderr&lt;BR /&gt;{&lt;BR /&gt;cmd&lt;BR /&gt;} &amp;gt;outfile 2&amp;gt;errorfile&lt;BR /&gt;&lt;BR /&gt;2) Redirect one stream to the other&lt;BR /&gt;{&lt;BR /&gt;cmd&lt;BR /&gt;} &amp;gt;outfile 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Tue, 25 Apr 2006 11:23:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975415#M99269</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-04-25T11:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: Output redirection help in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975416#M99270</link>
      <description>If you are running in a script, you have the option to assign STDOUT and STDERR before the fbackup command and thus capture all output. Example- &lt;BR /&gt; &lt;BR /&gt;exec &amp;gt;$logfile 2&amp;gt;&amp;amp;1&lt;BR /&gt;date&lt;BR /&gt;fbackup ...&lt;BR /&gt;date&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 25 Apr 2006 11:29:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975416#M99270</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2006-04-25T11:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Output redirection help in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975417#M99271</link>
      <description>Hi Mike:&lt;BR /&gt;&lt;BR /&gt;Order is important here, too!&lt;BR /&gt;&lt;BR /&gt;Run this script snippet:&lt;BR /&gt;&lt;BR /&gt;# cat .redir&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;echo      "from stdout"&lt;BR /&gt;print -u2 "from stderr"&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;...Do this:&lt;BR /&gt;&lt;BR /&gt;# ./redir 2&amp;gt;&amp;amp;1 1&amp;gt; /redir.log&lt;BR /&gt;from stderr&lt;BR /&gt;# cat redir.log&lt;BR /&gt;from stdout&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Now:&lt;BR /&gt;&lt;BR /&gt;# ./redir 1&amp;gt; /redir.log 2&amp;gt;&amp;amp;1 &lt;BR /&gt;# cat redir.log&lt;BR /&gt;from stdout&lt;BR /&gt;from stderr&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;# &lt;BR /&gt;</description>
      <pubDate>Tue, 25 Apr 2006 11:53:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975417#M99271</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-04-25T11:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: Output redirection help in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975418#M99272</link>
      <description>Ok, so for I have tried what Harry recommended, the backups ran sucessfully so there were no errors but still I got output to the screen instead of to the file.&lt;BR /&gt;&lt;BR /&gt;Actual code:&lt;BR /&gt;{ fbackup $backup_type -u $verbose_option $nfs_option -g $graph_file $index_opt &lt;BR /&gt;} &amp;amp;1 1&amp;gt;$logfile &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Actual output&lt;BR /&gt;&lt;BR /&gt;+ 0&amp;lt; /bow/resp 2&amp;gt;&amp;amp; 1 + fbackup -0 -u -n -g /bow/bowgraph -I /bow/backuplogs/25Apr06.full -c /bow/backup_config -d /bow/fbackupfilesm&lt;BR /&gt;fbackup(1004): session begins on Tue Apr 25 13:04:09 2006&lt;BR /&gt;fbackup(3203): volume 1 has been used 8 time(s)&lt;BR /&gt;fbackup(3024): writing volume 1 to the output file /dev/rmt/0m&lt;BR /&gt;fbackup(3055): total file blocks read for backup: 25676534&lt;BR /&gt;fbackup(3056): total blocks written to output file /dev/rmt/0m: 26241878&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The output file is completely empty.  Did I miss something?</description>
      <pubDate>Tue, 25 Apr 2006 12:12:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975418#M99272</guid>
      <dc:creator>Mike Smith_33</dc:creator>
      <dc:date>2006-04-25T12:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: Output redirection help in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975419#M99273</link>
      <description>You can do as I suggested. But the error is you assign 2 before 1. Reverse them...&lt;BR /&gt; &lt;BR /&gt;&amp;gt;$logfile 2&amp;gt;&amp;amp;1&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 25 Apr 2006 12:16:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975419#M99273</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2006-04-25T12:16:06Z</dc:date>
    </item>
    <item>
      <title>Re: Output redirection help in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975420#M99274</link>
      <description>Hi (again) Mike:&lt;BR /&gt;&lt;BR /&gt;With regard to your second question, see my post just above:  "Order is important here, too!"&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 25 Apr 2006 12:17:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975420#M99274</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-04-25T12:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: Output redirection help in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975421#M99275</link>
      <description>James, I am running your script tests now and I am beginning to get what you are saying.  It looks like I just need to change the order.  I have a meeting in 6 minutes, I will retest after that.</description>
      <pubDate>Tue, 25 Apr 2006 12:24:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975421#M99275</guid>
      <dc:creator>Mike Smith_33</dc:creator>
      <dc:date>2006-04-25T12:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: Output redirection help in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975422#M99276</link>
      <description>Just got a chance to try James' suggestion and here is what I got.&lt;BR /&gt;&lt;BR /&gt;{ fbackup $backup_type -u $verbose_option $nfs_option -g $graph_file $index_option -c $config_file -d $fbackupfiles -f $device&lt;BR /&gt;} $logfile 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;fbackup(1004): session begins on Tue Apr 25 15:02:37 2006&lt;BR /&gt;fbackup(3203): volume 1 has been used 9 time(s)&lt;BR /&gt;fbackup(3024): writing volume 1 to the output file /dev/rmt/0m&lt;BR /&gt;fbackup(3055): total file blocks read for backup: 21220083&lt;BR /&gt;fbackup(3056): total blocks written to output file /dev/rmt/0m: 21787601&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Still no output in the file.  I will now try the method given by Rodney.</description>
      <pubDate>Tue, 25 Apr 2006 14:13:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975422#M99276</guid>
      <dc:creator>Mike Smith_33</dc:creator>
      <dc:date>2006-04-25T14:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: Output redirection help in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975423#M99277</link>
      <description>Are those curly brackets you are using?&lt;BR /&gt; &lt;BR /&gt;If so then the syntax requires a ; before the closing right curly bracket.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 25 Apr 2006 14:22:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975423#M99277</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2006-04-25T14:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: Output redirection help in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975424#M99278</link>
      <description>This one didn't work either but I am confused as to why, it made sense.&lt;BR /&gt;&lt;BR /&gt;{ fbackup $backup_type -u $verbose_option $nfs_option -g $graph_file $index_opt &lt;BR /&gt;} $logfile 2&amp;gt;&amp;amp;1 &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;+ fbackup -0 -u -n -g /bow/bowgraph -I /bow/backuplogs/25Apr06.full -c /bow/backup_config -d /bow/fbackupfiles/dates -f /dev/rmt/0m&lt;BR /&gt;fbackup(1004): session begins on Tue Apr 25 15:18:36 2006&lt;BR /&gt;fbackup(3203): volume 1 has been used 10 time(s)&lt;BR /&gt;fbackup(3024): writing volume 1 to the output file /dev/rmt/0m&lt;BR /&gt;fbackup(1102): WARNING: unable to stat file /entsys/tmp/cos.003354981498422125.1385.6&lt;BR /&gt;fbackup(3005): WARNING: file number 33092 was NOT backed up&lt;BR /&gt;fbackup(1030): warnings encountered during backup&lt;BR /&gt;fbackup(3055): total file blocks read for backup: 21283397&lt;BR /&gt;fbackup(3056): total blocks written to output file /dev/rmt/0m: 21851691&lt;BR /&gt;</description>
      <pubDate>Tue, 25 Apr 2006 14:29:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975424#M99278</guid>
      <dc:creator>Mike Smith_33</dc:creator>
      <dc:date>2006-04-25T14:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: Output redirection help in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975425#M99279</link>
      <description>Hi (again) Mike:&lt;BR /&gt;&lt;BR /&gt;As Rodney noted, a a final semicolon is required after the last statement in curly braces.  I agree that you last post seems correct otherwise.  That aside, I use this in one of my scripts:&lt;BR /&gt;&lt;BR /&gt;# ( /usr/sbin/fbackup -f $FB_DEV -0 -u -v -g $FB_GRF -V $FB_VOL -c $FB_CNF 2&amp;gt;&amp;amp;1 ; echo $? &amp;gt; $FB_XIT ) | tee -ia $FB_LOG&lt;BR /&gt;&lt;BR /&gt;The approach I that I took here uses a sub process (and yes, there is not a semicolon in this syntax) but writes STDOUT and STDERR to ${FB_LOG} as well as the terminal.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 25 Apr 2006 14:50:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975425#M99279</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-04-25T14:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: Output redirection help in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975426#M99280</link>
      <description>I have added the semi colon before the right bracket and still the output comes to the screen.  From what I understand of the output and error redirection this should work&lt;BR /&gt;&lt;BR /&gt;1&amp;gt;$logfile 2&amp;gt;&amp;amp;1 &lt;BR /&gt;&lt;BR /&gt;This fbackup command is inside a script and I am trying to save the output and/or error/warnings in the $logfile.  I am apparently not seeing what is wrong with the syntax.</description>
      <pubDate>Tue, 25 Apr 2006 14:58:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975426#M99280</guid>
      <dc:creator>Mike Smith_33</dc:creator>
      <dc:date>2006-04-25T14:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: Output redirection help in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975427#M99281</link>
      <description>shouldn't your redirection line be:&lt;BR /&gt;&lt;BR /&gt;2&amp;gt;&amp;amp;1 &amp;gt;&amp;gt; $logfile</description>
      <pubDate>Tue, 25 Apr 2006 15:05:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975427#M99281</guid>
      <dc:creator>Christian Tremblay</dc:creator>
      <dc:date>2006-04-25T15:05:03Z</dc:date>
    </item>
    <item>
      <title>Re: Output redirection help in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975428#M99282</link>
      <description>Some of the earlier answers were correct, it was my mistake in that I should have been using $log_file instead of $logfile.  I would have found the answer much sooner.&lt;BR /&gt;&lt;BR /&gt;Thanks for all the help and for putting up with my typo.</description>
      <pubDate>Tue, 25 Apr 2006 15:11:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/output-redirection-help-in-ksh-script/m-p/4975428#M99282</guid>
      <dc:creator>Mike Smith_33</dc:creator>
      <dc:date>2006-04-25T15:11:37Z</dc:date>
    </item>
  </channel>
</rss>

