<?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 Inserting \ character in a string passed to another command in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090353#M806497</link>
    <description>Greetings,&lt;BR /&gt;&lt;BR /&gt;I have a shell script that receives a command line and executes a remote shell and passes the command string as argument.&lt;BR /&gt;&lt;BR /&gt;Content of shell script:&lt;BR /&gt;&lt;BR /&gt;cmd=$1&lt;BR /&gt;remsh host1 -l user1 -n "export DISPLAY=$DISPLAY;/opt/app/xpto.sh $cmd &lt;BR /&gt;&lt;BR /&gt;This executes:&lt;BR /&gt;&lt;BR /&gt;remsh host1 -l user1 -n "export DISPLAY=$DISPLAY;/opt/app/xpto.sh xpto (12) &lt;BR /&gt;&lt;BR /&gt;When executing, I get the error:&lt;BR /&gt;&lt;BR /&gt;I get the error&lt;BR /&gt;&lt;BR /&gt;sh: Syntax error at line 1 : `(' is not expected.&lt;BR /&gt;&lt;BR /&gt;I am trying to insert some \ character before the (  character but without success:&lt;BR /&gt;&lt;BR /&gt;parsed_cmd=`echo $cmd | sed "s/(/\\0050/g" | sed "s/(/\(/g"`&lt;BR /&gt;&lt;BR /&gt;Any help/suggestion is highly appreciated.&lt;BR /&gt;TIA.&lt;BR /&gt;&lt;BR /&gt;Kind Regards,&lt;BR /&gt;&lt;BR /&gt;Rui.</description>
    <pubDate>Fri, 10 Oct 2003 04:24:00 GMT</pubDate>
    <dc:creator>Rui Vilao</dc:creator>
    <dc:date>2003-10-10T04:24:00Z</dc:date>
    <item>
      <title>Inserting \ character in a string passed to another command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090353#M806497</link>
      <description>Greetings,&lt;BR /&gt;&lt;BR /&gt;I have a shell script that receives a command line and executes a remote shell and passes the command string as argument.&lt;BR /&gt;&lt;BR /&gt;Content of shell script:&lt;BR /&gt;&lt;BR /&gt;cmd=$1&lt;BR /&gt;remsh host1 -l user1 -n "export DISPLAY=$DISPLAY;/opt/app/xpto.sh $cmd &lt;BR /&gt;&lt;BR /&gt;This executes:&lt;BR /&gt;&lt;BR /&gt;remsh host1 -l user1 -n "export DISPLAY=$DISPLAY;/opt/app/xpto.sh xpto (12) &lt;BR /&gt;&lt;BR /&gt;When executing, I get the error:&lt;BR /&gt;&lt;BR /&gt;I get the error&lt;BR /&gt;&lt;BR /&gt;sh: Syntax error at line 1 : `(' is not expected.&lt;BR /&gt;&lt;BR /&gt;I am trying to insert some \ character before the (  character but without success:&lt;BR /&gt;&lt;BR /&gt;parsed_cmd=`echo $cmd | sed "s/(/\\0050/g" | sed "s/(/\(/g"`&lt;BR /&gt;&lt;BR /&gt;Any help/suggestion is highly appreciated.&lt;BR /&gt;TIA.&lt;BR /&gt;&lt;BR /&gt;Kind Regards,&lt;BR /&gt;&lt;BR /&gt;Rui.</description>
      <pubDate>Fri, 10 Oct 2003 04:24:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090353#M806497</guid>
      <dc:creator>Rui Vilao</dc:creator>
      <dc:date>2003-10-10T04:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting \ character in a string passed to another command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090354#M806498</link>
      <description>echo $cmd|sed -e "s/(/\\\\(/" -e "s/)/\\\\)/"&lt;BR /&gt;-- Graham</description>
      <pubDate>Fri, 10 Oct 2003 05:15:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090354#M806498</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2003-10-10T05:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting \ character in a string passed to another command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090355#M806499</link>
      <description>Graham,&lt;BR /&gt;&lt;BR /&gt;Thanks for your suggestion.&lt;BR /&gt;&lt;BR /&gt;The problem is if you have this within a script it will fail:&lt;BR /&gt;&lt;BR /&gt;In script:&lt;BR /&gt;&lt;BR /&gt;remsh host1 -l user1 -n "export DISPLAY=$DISPLAY;echo $parsed_cmd"&lt;BR /&gt;&lt;BR /&gt;It returns:&lt;BR /&gt;&lt;BR /&gt;ksh: syntax error at line 1 : `(' unexpected&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;TIA,&lt;BR /&gt;&lt;BR /&gt;Rui.</description>
      <pubDate>Fri, 10 Oct 2003 05:35:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090355#M806499</guid>
      <dc:creator>Rui Vilao</dc:creator>
      <dc:date>2003-10-10T05:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting \ character in a string passed to another command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090356#M806500</link>
      <description>I'm still struggling to understand exactly what you are trying to do here but it is a Friday!&lt;BR /&gt; &lt;BR /&gt;If I understand you correctly I would have though enclosing $cmd in " marks might help.  You might need to enclose it with \" if being part of the remsh though.</description>
      <pubDate>Fri, 10 Oct 2003 05:49:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090356#M806500</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2003-10-10T05:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting \ character in a string passed to another command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090357#M806501</link>
      <description>Looks ok to me...&lt;BR /&gt;--&lt;BR /&gt;#PS1="# " &lt;BR /&gt;# cmd="xpto (12)"                                            &lt;BR /&gt;# parsed_cmd=$(echo $cmd|sed -e "s/(/\\\\(/" -e "s/)/\\\\)/")&lt;BR /&gt;# echo $parsed_cmd                                           &lt;BR /&gt;xpto \(12\)&lt;BR /&gt;# remsh crimple "echo $parsed_cmd"                           &lt;BR /&gt;xpto (12)&lt;BR /&gt;# &lt;BR /&gt;--&lt;BR /&gt;-- Graham</description>
      <pubDate>Fri, 10 Oct 2003 06:05:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090357#M806501</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2003-10-10T06:05:03Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting \ character in a string passed to another command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090358#M806502</link>
      <description>&lt;BR /&gt;You are right I was not clear enough...&lt;BR /&gt;This is my script:&lt;BR /&gt;&lt;BR /&gt;cat cmd.sh&lt;BR /&gt;#! /usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;cmd="COMMAND (12)"&lt;BR /&gt;&lt;BR /&gt;parsed_cmd=`echo $cmd|sed -e "s/(/\\\\(/" -e "s/)/\\\\)/"`&lt;BR /&gt;&lt;BR /&gt;remsh host1 -l user1 -n "export DISPLAY=$DISPLAY;echo $parsed_cmd"&lt;BR /&gt;&lt;BR /&gt;... and it returns:&lt;BR /&gt;&lt;BR /&gt;ksh: syntax error at line 1 : `(' unexpected&lt;BR /&gt;&lt;BR /&gt;TIA,&lt;BR /&gt;&lt;BR /&gt;Rui.</description>
      <pubDate>Fri, 10 Oct 2003 06:05:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090358#M806502</guid>
      <dc:creator>Rui Vilao</dc:creator>
      <dc:date>2003-10-10T06:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting \ character in a string passed to another command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090359#M806503</link>
      <description>Rui&lt;BR /&gt;It's the backticks.&lt;BR /&gt;Change&lt;BR /&gt;--&lt;BR /&gt;parsed_cmd=`echo $cmd|sed -e "s/(/\\\\(/" -e "s/)/\\\\)/"`&lt;BR /&gt;-- to --&lt;BR /&gt;parsed_cmd=$(echo $cmd|sed -e "s/(/\\\\(/" -e "s/)/\\\\)/")&lt;BR /&gt;-- Graham</description>
      <pubDate>Fri, 10 Oct 2003 06:14:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090359#M806503</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2003-10-10T06:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting \ character in a string passed to another command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090360#M806504</link>
      <description>I still think putting escaped quotation marks around $parsed_command should work.</description>
      <pubDate>Fri, 10 Oct 2003 06:25:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090360#M806504</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2003-10-10T06:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting \ character in a string passed to another command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090361#M806505</link>
      <description>Hi,&lt;BR /&gt;...and I think that the error resembles what  you get when doing this:&lt;BR /&gt;$ cmd=COMMAND (12)&lt;BR /&gt;ksh: syntax error: `(' unexpected&lt;BR /&gt; &lt;BR /&gt;In your first posting you say that the content of the shell script is:&lt;BR /&gt;cmd=$1&lt;BR /&gt; &lt;BR /&gt;If this is in fact the case, try changing it to:&lt;BR /&gt;cmd="$"&lt;BR /&gt; &lt;BR /&gt;regards,&lt;BR /&gt;John K.&lt;BR /&gt;</description>
      <pubDate>Fri, 10 Oct 2003 07:08:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090361#M806505</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2003-10-10T07:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting \ character in a string passed to another command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090362#M806506</link>
      <description>&lt;BR /&gt;Many thanks to Graham Cameron.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;Rui</description>
      <pubDate>Sat, 11 Oct 2003 07:43:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/inserting-character-in-a-string-passed-to-another-command/m-p/3090362#M806506</guid>
      <dc:creator>Rui Vilao</dc:creator>
      <dc:date>2003-10-11T07:43:44Z</dc:date>
    </item>
  </channel>
</rss>

