<?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: Shell variable containing pipe in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-variable-containing-pipe/m-p/3074389#M141376</link>
    <description>Normal behavior! :)&lt;BR /&gt;&lt;BR /&gt;Use:&lt;BR /&gt;#COMMAND=`echo hello|grep hell`&lt;BR /&gt;#echo $COMMAND&lt;BR /&gt;&lt;BR /&gt;Regards,STAN</description>
    <pubDate>Thu, 18 Sep 2003 14:57:38 GMT</pubDate>
    <dc:creator>Stanimir</dc:creator>
    <dc:date>2003-09-18T14:57:38Z</dc:date>
    <item>
      <title>Shell variable containing pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-variable-containing-pipe/m-p/3074387#M141374</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;Can someone explain why a remote shell interprets a pipe, but a local shell doesn't?&lt;BR /&gt;e.g.&lt;BR /&gt;# COMMAND='echo hello | grep hell'&lt;BR /&gt;# remsh other_host $COMMAND&lt;BR /&gt;hello&lt;BR /&gt;# $COMMAND&lt;BR /&gt;hello | grep hell&lt;BR /&gt;&lt;BR /&gt;Why does the local shell execute the echo, but not react to the pipe?&lt;BR /&gt;What syntax should I use to get the same result as the remsh?</description>
      <pubDate>Thu, 18 Sep 2003 14:41:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-variable-containing-pipe/m-p/3074387#M141374</guid>
      <dc:creator>Stephen Mudd</dc:creator>
      <dc:date>2003-09-18T14:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: Shell variable containing pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-variable-containing-pipe/m-p/3074388#M141375</link>
      <description>your command worked. Works fine for me with a pipe in a variable or not.&lt;BR /&gt;&lt;BR /&gt;You did the remote command;&lt;BR /&gt;&lt;BR /&gt;echo hello | grep hell&lt;BR /&gt;&lt;BR /&gt;and hell is part of hello so it echoed back hello. This is normal behaviour.&lt;BR /&gt;</description>
      <pubDate>Thu, 18 Sep 2003 14:48:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-variable-containing-pipe/m-p/3074388#M141375</guid>
      <dc:creator>Stefan Farrelly</dc:creator>
      <dc:date>2003-09-18T14:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: Shell variable containing pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-variable-containing-pipe/m-p/3074389#M141376</link>
      <description>Normal behavior! :)&lt;BR /&gt;&lt;BR /&gt;Use:&lt;BR /&gt;#COMMAND=`echo hello|grep hell`&lt;BR /&gt;#echo $COMMAND&lt;BR /&gt;&lt;BR /&gt;Regards,STAN</description>
      <pubDate>Thu, 18 Sep 2003 14:57:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-variable-containing-pipe/m-p/3074389#M141376</guid>
      <dc:creator>Stanimir</dc:creator>
      <dc:date>2003-09-18T14:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Shell variable containing pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-variable-containing-pipe/m-p/3074390#M141377</link>
      <description>/agree &lt;BR /&gt;&lt;BR /&gt;On your local host, the echo command only regurgitates what you give it in quotes, it will not treat it as an executable command... merely as plain text.&lt;BR /&gt;&lt;BR /&gt;You would have to pass the variable to a script or one-liner... or change the quotes to back tics... as below.&lt;BR /&gt;&lt;BR /&gt;You will need to change it to back tics..the one next to the 1 key....&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# COMMAND=`echo hello | grep hello`&lt;BR /&gt;# echo $COMMAND                    &lt;BR /&gt;hello</description>
      <pubDate>Thu, 18 Sep 2003 14:58:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-variable-containing-pipe/m-p/3074390#M141377</guid>
      <dc:creator>Todd McDaniel_1</dc:creator>
      <dc:date>2003-09-18T14:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: Shell variable containing pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-variable-containing-pipe/m-p/3074391#M141378</link>
      <description>Its amazing to me 3 of us posted at the exact same time LOL... I didnt copy the guy above me LOL...so please dont penalize me on points!!&lt;BR /&gt;&lt;BR /&gt;of course zero for this post of course!</description>
      <pubDate>Thu, 18 Sep 2003 15:03:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-variable-containing-pipe/m-p/3074391#M141378</guid>
      <dc:creator>Todd McDaniel_1</dc:creator>
      <dc:date>2003-09-18T15:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: Shell variable containing pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-variable-containing-pipe/m-p/3074392#M141379</link>
      <description>Sorry Tod!&lt;BR /&gt;Really your answer is more complete&lt;BR /&gt;and usefull.&lt;BR /&gt;&lt;BR /&gt;Regards,Stan</description>
      <pubDate>Thu, 18 Sep 2003 15:06:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-variable-containing-pipe/m-p/3074392#M141379</guid>
      <dc:creator>Stanimir</dc:creator>
      <dc:date>2003-09-18T15:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Shell variable containing pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-variable-containing-pipe/m-p/3074393#M141380</link>
      <description>It has to do when the shell is interpreting the command.&lt;BR /&gt;&lt;BR /&gt;On the local system&lt;BR /&gt;$COMMAND&lt;BR /&gt;is replaced with the the contents of COMMAND and the echo command is executed. But the "|" has no meaning except on the command line you typed. It is not processed by the shell.&lt;BR /&gt;&lt;BR /&gt;If you wanted $COMMAND to recognize the "|", then use the "eval" shell command (see man sh-posix).&lt;BR /&gt;eval $COMMAND&lt;BR /&gt;&lt;BR /&gt;Then the shell will rescan the command line a second time, see the "|" and do the pipe operation.&lt;BR /&gt;&lt;BR /&gt;The reason it works on the remsh is the same situation. When $COMMAND is run on the remote host, the remote host shell rescans the command line and sees the "|" as its special meaning.&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Thu, 18 Sep 2003 15:37:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-variable-containing-pipe/m-p/3074393#M141380</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-09-18T15:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: Shell variable containing pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-variable-containing-pipe/m-p/3074394#M141381</link>
      <description>Thanks for your replies.  I should have realised what was going on without making myself look like a complete novice.  Never mind.  We all have off days occasionally.&lt;BR /&gt;&lt;BR /&gt;Using "eval" is preferable to using "echo $(command)" or backquotes because it retains the formatting, e.g.&lt;BR /&gt;&lt;BR /&gt;# COMMAND1="/usr/sbin/lanscan |cut -c1-8,24-80"&lt;BR /&gt;# COMMAND2=$(/usr/sbin/lanscan |cut -c1-8,24-80)&lt;BR /&gt;# echo $COMMAND2&lt;BR /&gt;Hardware Crd Hdw Net-Interface NM MAC HP-DLPI DLPI Path In# State NamePPA ID Type Support Mjr# 0/0/0/0 0 UP lan0 snap0 1 ETHER Yes 119 0/4/0/0 1 UP lan1 snap1 2 ETHER Yes 119 0/6/0/0 2 UP lan2 snap2 3 ETHER Yes 119 0/2/0/0 0 UP ixe1 5 X25 No 77 0/2/0/0 0 UP ixe2 6 X25 No 77&lt;BR /&gt;# eval $COMMAND1&lt;BR /&gt;Hardware Crd  Hdw   Net-Interface    NM   MAC       HP-DLPI DLPI&lt;BR /&gt;Path     In#  State NamePPA          ID   Type      Support Mjr#&lt;BR /&gt;0/0/0/0  0    UP    lan0 snap0       1    ETHER       Yes   119&lt;BR /&gt;0/4/0/0  1    UP    lan1 snap1       2    ETHER       Yes   119&lt;BR /&gt;0/6/0/0  2    UP    lan2 snap2       3    ETHER       Yes   119&lt;BR /&gt;0/2/0/0  0    UP    ixe1             5    X25         No    77&lt;BR /&gt;0/2/0/0  0    UP    ixe2             6    X25         No    77&lt;BR /&gt;# remsh other_host $COMMAND1&lt;BR /&gt;Hardware Crd  Hdw   Net-Interface    NM   MAC       HP-DLPI DLPI&lt;BR /&gt;Path     In#  State NamePPA          ID   Type      Support Mjr#&lt;BR /&gt;0/0/0/0  0    UP    lan0 snap0       1    ETHER       Yes   119&lt;BR /&gt;0/5/0/0  2    UP    lan2 snap2       2    ETHER       Yes   119&lt;BR /&gt;0/10/0/0 1    UP    lan1 snap1       3    ETHER       Yes   119&lt;BR /&gt;0/8/0/0  0    UP    ixe1             5    X25         No    79&lt;BR /&gt;0/8/0/0  0    UP    ixe2             6    X25         No    7</description>
      <pubDate>Thu, 18 Sep 2003 16:26:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-variable-containing-pipe/m-p/3074394#M141381</guid>
      <dc:creator>Stephen Mudd</dc:creator>
      <dc:date>2003-09-18T16:26:35Z</dc:date>
    </item>
  </channel>
</rss>

