<?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: korn shell: dynamic use of here docs in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-dynamic-use-of-the-eof-execution-method/m-p/5673035#M638147</link>
    <description>&lt;P&gt;&amp;gt;is there a difference between: cat &amp;lt;&amp;lt;-EOF&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As documented, that "-" causes all leading tabs to be removed&lt;/P&gt;</description>
    <pubDate>Tue, 29 May 2012 13:28:43 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2012-05-29T13:28:43Z</dc:date>
    <item>
      <title>korn shell: dynamic use of the EOF execution method</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-dynamic-use-of-the-eof-execution-method/m-p/5668201#M638144</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I have following issue :&lt;BR /&gt;&lt;BR /&gt;I use in a shell script an oracle command ( RMAN ). i use the RMAN command by using the EOF execution method like below.&lt;BR /&gt;but the part of the channels should by dynamic. how can i create the &lt;STRONG&gt;EOF&lt;/STRONG&gt; part dynamic ? with a temporary file ?&lt;BR /&gt;&lt;BR /&gt;the input should be the number of channels and depend of the nummer i should create dynamic channels in the &lt;STRONG&gt;EOF&lt;/STRONG&gt; part&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;NOW:&lt;BR /&gt;rman &amp;lt;&amp;lt;-EOF&lt;BR /&gt;connect catalog rman/${RMAN_CONNECT}@${RMAN_SID}&lt;BR /&gt;connect target&amp;nbsp; /&lt;BR /&gt;run {&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; allocate channel dev_1 type 'SBT_TAPE';&lt;/STRONG&gt;&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; release channel dev_1;&lt;/STRONG&gt;&lt;BR /&gt;}&lt;BR /&gt;EOF&lt;BR /&gt;&lt;BR /&gt;NEW:&lt;BR /&gt;nr_channels=3&amp;nbsp; # so 3 channels should be exist in the EOF part&lt;BR /&gt;&lt;BR /&gt;# create the dynamic part of channels&lt;BR /&gt;rman &amp;lt;&amp;lt;-EOF&lt;BR /&gt;connect catalog rman/${RMAN_CONNECT}@${RMAN_SID}&lt;BR /&gt;connect target&amp;nbsp; /&lt;BR /&gt;run {&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; allocate channel dev_1 type 'SBT_TAPE';&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; allocate channel dev_2 type 'SBT_TAPE';&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; allocate channel dev_3 type 'SBT_TAPE';&lt;/STRONG&gt;&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; release channel dev_3;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; release channel dev_2;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; release channel dev_1;&lt;/STRONG&gt;&lt;BR /&gt;}&lt;BR /&gt;EOF&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2012 12:24:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-dynamic-use-of-the-eof-execution-method/m-p/5668201#M638144</guid>
      <dc:creator>support_billa</dc:creator>
      <dc:date>2012-05-24T12:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: korn shell: dynamic use of here docs</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-dynamic-use-of-the-eof-execution-method/m-p/5668585#M638145</link>
      <description>&lt;P&gt;&amp;gt;i use the RMAN command by using the EOF execution method&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(These are called here documents or here docs.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;how can i create the &lt;STRONG&gt;EOF&lt;/STRONG&gt; part dynamic? with a temporary file?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Whatever is easiest and can be understood and maintained.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A separate file with echo and cat may be easiest.&amp;nbsp; But you can put scripts into the here doc:&lt;/P&gt;&lt;P&gt;rman &amp;lt;&amp;lt;-EOF&lt;BR /&gt;connect catalog rman/${RMAN_CONNECT}@${RMAN_SID}&lt;BR /&gt;connect target&amp;nbsp; /&lt;BR /&gt;run {&lt;/P&gt;&lt;P&gt;$(&lt;/P&gt;&lt;P&gt;for i in dev_1 dev_2 dev_3; do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; echo "&amp;nbsp;&amp;nbsp; allocate channel $i type 'SBT_TAPE';"&lt;/P&gt;&lt;P&gt;done&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;$(&lt;/P&gt;&lt;P&gt;for i in dev_3 dev_2 dev_1; do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; echo " &amp;nbsp; release channel $i;"&lt;BR /&gt;done&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;EOF&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it may be easier to just create a temp file:&lt;/P&gt;&lt;P&gt;tmp_file=/var/tmp/tf.$$&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;cat &amp;lt;&amp;lt;-EOF1&lt;/P&gt;&lt;P&gt;connect catalog rman/${RMAN_CONNECT}@${RMAN_SID}&lt;BR /&gt;connect target&amp;nbsp; /&lt;BR /&gt;run {&lt;/P&gt;&lt;P&gt;EOF1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for i in dev_1 dev_2 dev_3; do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; echo "&amp;nbsp;&amp;nbsp; allocate channel $i type 'SBT_TAPE';"&lt;/P&gt;&lt;P&gt;done&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cat &amp;lt;&amp;lt;-EOF2&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;EOF2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for i in dev_3 dev_2 dev_1; do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; echo " &amp;nbsp; release channel $i;"&lt;BR /&gt;done&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;cat &amp;lt;&amp;lt;-EOF3&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;EOF3&lt;/P&gt;&lt;P&gt;} &amp;gt; $tmp_file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;rman &amp;lt; $tmp_file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;rm -f $tmp_file&amp;nbsp; # cleanup&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2012 20:03:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-dynamic-use-of-the-eof-execution-method/m-p/5668585#M638145</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2012-05-24T20:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: korn shell: dynamic use of here docs</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-dynamic-use-of-the-eof-execution-method/m-p/5672879#M638146</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i prefer option 1, but option 2 is also an alternative.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here my solution :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;NR_CHANNELS=3  # define number of channels, starts with "0"
i=0
(( ii = NR_CHANNELS - 1 ))

rman &amp;lt;&amp;lt;-EOF
..
#  allocate channel : dynamic part
#  allocate channel dev_0 type 'SBT_TAPE';
$( 
while [ ${i} -lt ${NR_CHANNELS} ]; do
  echo "allocate channel dev_${i} type 'SBT_TAPE';"
  (( i += 1 ))
done
)
#  release channel : dynamic part
#  release channel dev_0;
$( 
until [ ${ii} -lt 0 ]; do
  echo "release channel dev_${ii};"
  (( ii -= 1 ))
done
)
}
EOF&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;last question :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there a difference between :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cat &amp;lt;&amp;lt;-EOF&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cat &amp;lt;&amp;lt;EOF&amp;nbsp; ( without "-" )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2012 11:23:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-dynamic-use-of-the-eof-execution-method/m-p/5672879#M638146</guid>
      <dc:creator>support_billa</dc:creator>
      <dc:date>2012-05-29T11:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: korn shell: dynamic use of here docs</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-dynamic-use-of-the-eof-execution-method/m-p/5673035#M638147</link>
      <description>&lt;P&gt;&amp;gt;is there a difference between: cat &amp;lt;&amp;lt;-EOF&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As documented, that "-" causes all leading tabs to be removed&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2012 13:28:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-dynamic-use-of-the-eof-execution-method/m-p/5673035#M638147</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2012-05-29T13:28:43Z</dc:date>
    </item>
  </channel>
</rss>

