<?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 script output to both log file and to my screen window.. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-to-both-log-file-and-to-my-screen-window/m-p/3180178#M718178</link>
    <description>We have set some scripts up to log all of their output to log files, because we lost some log files in the past:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; &lt;BR /&gt;&amp;gt; LOGDIR=/var/opt/timefinder/logs&lt;BR /&gt;&amp;gt; SCRIPT=$(basename $0 .ksh)&lt;BR /&gt;&amp;gt; BCVSET=$1&lt;BR /&gt;&amp;gt; LOGDATE=$(date +%m%d%y-%H%M)&lt;BR /&gt;&amp;gt; LOG=${LOGDIR}/${SCRIPT}_${BCVSET}.${LOGDATE}.log&lt;BR /&gt;&amp;gt; exec 2&amp;gt;${LOG}&lt;BR /&gt;&amp;gt; exec &amp;gt;&amp;amp;2&lt;BR /&gt;&amp;gt;&lt;BR /&gt;&amp;gt;  (script commands)&lt;BR /&gt;&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;So, all of the script output goes to $LOGDIR/script_name_date.log&lt;BR /&gt;&lt;BR /&gt;But, when I run the script manually (to test changes, etc), I want the output to go to my screen window (and to the log file..)..&lt;BR /&gt;&lt;BR /&gt;Can I do something, in the script, like:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; exec 1&amp;gt;${LOG} 2&amp;gt;&amp;amp;1 tee "screen window"&lt;BR /&gt;&lt;BR /&gt;  Stuart&lt;BR /&gt;</description>
    <pubDate>Mon, 02 Feb 2004 10:18:10 GMT</pubDate>
    <dc:creator>Stuart Abramson_2</dc:creator>
    <dc:date>2004-02-02T10:18:10Z</dc:date>
    <item>
      <title>script output to both log file and to my screen window..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-to-both-log-file-and-to-my-screen-window/m-p/3180178#M718178</link>
      <description>We have set some scripts up to log all of their output to log files, because we lost some log files in the past:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; &lt;BR /&gt;&amp;gt; LOGDIR=/var/opt/timefinder/logs&lt;BR /&gt;&amp;gt; SCRIPT=$(basename $0 .ksh)&lt;BR /&gt;&amp;gt; BCVSET=$1&lt;BR /&gt;&amp;gt; LOGDATE=$(date +%m%d%y-%H%M)&lt;BR /&gt;&amp;gt; LOG=${LOGDIR}/${SCRIPT}_${BCVSET}.${LOGDATE}.log&lt;BR /&gt;&amp;gt; exec 2&amp;gt;${LOG}&lt;BR /&gt;&amp;gt; exec &amp;gt;&amp;amp;2&lt;BR /&gt;&amp;gt;&lt;BR /&gt;&amp;gt;  (script commands)&lt;BR /&gt;&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;So, all of the script output goes to $LOGDIR/script_name_date.log&lt;BR /&gt;&lt;BR /&gt;But, when I run the script manually (to test changes, etc), I want the output to go to my screen window (and to the log file..)..&lt;BR /&gt;&lt;BR /&gt;Can I do something, in the script, like:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; exec 1&amp;gt;${LOG} 2&amp;gt;&amp;amp;1 tee "screen window"&lt;BR /&gt;&lt;BR /&gt;  Stuart&lt;BR /&gt;</description>
      <pubDate>Mon, 02 Feb 2004 10:18:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-to-both-log-file-and-to-my-screen-window/m-p/3180178#M718178</guid>
      <dc:creator>Stuart Abramson_2</dc:creator>
      <dc:date>2004-02-02T10:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: script output to both log file and to my screen window..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-to-both-log-file-and-to-my-screen-window/m-p/3180179#M718179</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;from man&lt;BR /&gt;&lt;BR /&gt; SYNOPSIS&lt;BR /&gt;      tee [-i] [-a] [file] ...&lt;BR /&gt;&lt;BR /&gt; DESCRIPTION&lt;BR /&gt;      The tee command transcribes the standard input to the standard output&lt;BR /&gt;      and makes copies in the files&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; EXAMPLES&lt;BR /&gt;      Write a list of users to the screen and also append the list to the&lt;BR /&gt;      file hunt:&lt;BR /&gt;&lt;BR /&gt;           who | tee -a hunt&lt;BR /&gt;&lt;BR /&gt;Thus &lt;BR /&gt;command 2&amp;gt;&amp;amp;1|tee -a $LOG&lt;BR /&gt;&lt;BR /&gt;              Steve Steel&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 02 Feb 2004 10:25:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-to-both-log-file-and-to-my-screen-window/m-p/3180179#M718179</guid>
      <dc:creator>Steve Steel</dc:creator>
      <dc:date>2004-02-02T10:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: script output to both log file and to my screen window..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-to-both-log-file-and-to-my-screen-window/m-p/3180180#M718180</link>
      <description>You'd need to use&lt;BR /&gt;&lt;BR /&gt;exec 2&amp;gt;&amp;amp;1 | tee -a ${LOG}&lt;BR /&gt;&lt;BR /&gt;This displays to screen, and appends to the log.</description>
      <pubDate>Mon, 02 Feb 2004 10:26:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-to-both-log-file-and-to-my-screen-window/m-p/3180180#M718180</guid>
      <dc:creator>Chris Wilshaw</dc:creator>
      <dc:date>2004-02-02T10:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: script output to both log file and to my screen window..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-to-both-log-file-and-to-my-screen-window/m-p/3180181#M718181</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Try with removing the exec commands from the script. When you want the output to log file only:&lt;BR /&gt;script &amp;gt;logfile&lt;BR /&gt;To screen AND logfile:&lt;BR /&gt;script | tee -a logfile</description>
      <pubDate>Mon, 02 Feb 2004 10:27:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-to-both-log-file-and-to-my-screen-window/m-p/3180181#M718181</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2004-02-02T10:27:43Z</dc:date>
    </item>
    <item>
      <title>Re: script output to both log file and to my screen window..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-to-both-log-file-and-to-my-screen-window/m-p/3180182#M718182</link>
      <description>Stuart&lt;BR /&gt;&lt;BR /&gt;Can't think of a quick way to do exactly what you ask, but how about?&lt;BR /&gt;&lt;BR /&gt;tail -f $LOGDIR/script_name_date.log&lt;BR /&gt;&lt;BR /&gt;-- Graham</description>
      <pubDate>Mon, 02 Feb 2004 10:27:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-to-both-log-file-and-to-my-screen-window/m-p/3180182#M718182</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2004-02-02T10:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: script output to both log file and to my screen window..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-to-both-log-file-and-to-my-screen-window/m-p/3180183#M718183</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;my suggestion would be:&lt;BR /&gt;&amp;gt; exec 2&amp;gt;&amp;amp;1 | tee -a ${LOG}&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 02 Feb 2004 10:30:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-to-both-log-file-and-to-my-screen-window/m-p/3180183#M718183</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2004-02-02T10:30:59Z</dc:date>
    </item>
  </channel>
</rss>

