<?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: KSH cmd var problem? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-cmd-var-problem/m-p/2745069#M721998</link>
    <description>To make it work-&lt;BR /&gt;&lt;BR /&gt;x="&amp;amp;1"&lt;BR /&gt;eval "echo 'This is a test' &amp;gt;$x"&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
    <pubDate>Fri, 14 Jun 2002 14:29:52 GMT</pubDate>
    <dc:creator>Rodney Hills</dc:creator>
    <dc:date>2002-06-14T14:29:52Z</dc:date>
    <item>
      <title>KSH cmd var problem?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-cmd-var-problem/m-p/2745066#M721995</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Come across this interesting situation, which no-one at my company is able to help with, so hoping one of you nice people can help...&lt;BR /&gt;&lt;BR /&gt;From a KSH command line, the following command works as expected, output goes to the screen.&lt;BR /&gt;&lt;BR /&gt;echo "This is a test" &amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;However, if you re-write it as follows, then the results are not the same, infact a file named '&amp;amp;1' is created.&lt;BR /&gt;&lt;BR /&gt;X="&amp;amp;1"; echo "This is a test" &amp;gt;${X}&lt;BR /&gt;&lt;BR /&gt;Why doesn't it work, and is there some way to make it work?&lt;BR /&gt;&lt;BR /&gt;Cheers in advance,&lt;BR /&gt;Robin Abecasis&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jun 2002 14:23:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-cmd-var-problem/m-p/2745066#M721995</guid>
      <dc:creator>Robin Abecasis</dc:creator>
      <dc:date>2002-06-14T14:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: KSH cmd var problem?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-cmd-var-problem/m-p/2745067#M721996</link>
      <description>ksh as well as other shells, do a one pass evaluation of the command line. Variables are substitued first, then the commands are executed.&lt;BR /&gt;&lt;BR /&gt;You would need to supply an "eval" somewhere to make it work.&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Fri, 14 Jun 2002 14:25:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-cmd-var-problem/m-p/2745067#M721996</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-06-14T14:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: KSH cmd var problem?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-cmd-var-problem/m-p/2745068#M721997</link>
      <description>Perhaps:&lt;BR /&gt;&lt;BR /&gt;X="1"; echo "This is a test" &amp;gt;&amp;amp;${X}&lt;BR /&gt;&lt;BR /&gt;There is something specific about the behavior of the varaible in this position.  I believe that the &amp;gt; and &amp;amp; characters form a token of sorts - the same kind of token that &amp;gt; and $ don't.</description>
      <pubDate>Fri, 14 Jun 2002 14:29:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-cmd-var-problem/m-p/2745068#M721997</guid>
      <dc:creator>A. Daniel King_1</dc:creator>
      <dc:date>2002-06-14T14:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: KSH cmd var problem?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-cmd-var-problem/m-p/2745069#M721998</link>
      <description>To make it work-&lt;BR /&gt;&lt;BR /&gt;x="&amp;amp;1"&lt;BR /&gt;eval "echo 'This is a test' &amp;gt;$x"&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Fri, 14 Jun 2002 14:29:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-cmd-var-problem/m-p/2745069#M721998</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-06-14T14:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: KSH cmd var problem?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-cmd-var-problem/m-p/2745070#M721999</link>
      <description>Many thanks for the solution, and it works for both files and screen. You're a star! :)&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Robin&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jun 2002 14:35:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-cmd-var-problem/m-p/2745070#M721999</guid>
      <dc:creator>Robin Abecasis</dc:creator>
      <dc:date>2002-06-14T14:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: KSH cmd var problem?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-cmd-var-problem/m-p/2745071#M722000</link>
      <description>To answer the question "why?"&lt;BR /&gt;&lt;BR /&gt;The shell (ksh, sh) interprets commands in a well-defined sequence:&lt;BR /&gt;Parse the line&lt;BR /&gt;Verbose trace&lt;BR /&gt;Parameter substitution&lt;BR /&gt;Command substitution&lt;BR /&gt;I/O redirection&lt;BR /&gt;IFS processing&lt;BR /&gt;Filename expansion&lt;BR /&gt;Execution trace&lt;BR /&gt;Run the command&lt;BR /&gt;&lt;BR /&gt;You might think that because I/O redirection comes after parameter substitution, this would make your original statement work, but the key is that '&amp;amp;' is a special character which the shell marks during the initial line parse.  This happens before the parameter substitution, so by the time you get to I/O redirection the '&amp;amp;1' is just another string to teh shell, not a stream file descriptor.&lt;BR /&gt;&lt;BR /&gt;This ends my uncrontrollable pedantism for today.  Please return to you rregularly scheduled lives.</description>
      <pubDate>Fri, 14 Jun 2002 14:56:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-cmd-var-problem/m-p/2745071#M722000</guid>
      <dc:creator>Alan Riggs</dc:creator>
      <dc:date>2002-06-14T14:56:17Z</dc:date>
    </item>
  </channel>
</rss>

