<?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: sprintf does not preserve quotes in c program in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sprintf-does-not-preserve-quotes-in-c-program/m-p/4292239#M688764</link>
    <description>&lt;!--!*#--&gt;&amp;gt; I am trying to [...]&lt;BR /&gt;&lt;BR /&gt;Perhaps an actual failing test program would&lt;BR /&gt;be easier to diagnose than waving hands.&lt;BR /&gt;&lt;BR /&gt;First, you should probably lose the "\n".&lt;BR /&gt;&lt;BR /&gt;My HP-UX system is off again, but:&lt;BR /&gt;&lt;BR /&gt;alp $ type sp3.c&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;char s[133];&lt;BR /&gt;&lt;BR /&gt;sprintf(s,"pipe write sys$output \"hel  lo\" &amp;gt; sp3.out");&lt;BR /&gt;system(s);&lt;BR /&gt;}&lt;BR /&gt;alp $ cc sp3&lt;BR /&gt;alp $ link sp3&lt;BR /&gt;alp $ run sp3&lt;BR /&gt;alp $ type sp3.out&lt;BR /&gt;hel  lo&lt;BR /&gt;alp $&lt;BR /&gt;&lt;BR /&gt;I'd say that the quotation is working.&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;</description>
    <pubDate>Wed, 22 Oct 2008 16:21:16 GMT</pubDate>
    <dc:creator>Steven Schweda</dc:creator>
    <dc:date>2008-10-22T16:21:16Z</dc:date>
    <item>
      <title>sprintf does not preserve quotes in c program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sprintf-does-not-preserve-quotes-in-c-program/m-p/4292234#M688759</link>
      <description>Greetings - C programming issue&lt;BR /&gt;I want to program to output double quotes - this works:&lt;BR /&gt;printf(" \"hello\" \n");  to output "hello"&lt;BR /&gt;this SHOULD work but does not:&lt;BR /&gt;sprintf(s,"\"hello\" \n");&lt;BR /&gt;system(s)     --output is just  hello without the double quotes. Why? thanks...&lt;BR /&gt;</description>
      <pubDate>Wed, 22 Oct 2008 14:08:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sprintf-does-not-preserve-quotes-in-c-program/m-p/4292234#M688759</guid>
      <dc:creator>Dave Chamberlin</dc:creator>
      <dc:date>2008-10-22T14:08:21Z</dc:date>
    </item>
    <item>
      <title>Re: sprintf does not preserve quotes in c program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sprintf-does-not-preserve-quotes-in-c-program/m-p/4292235#M688760</link>
      <description>Hi Dave:&lt;BR /&gt;&lt;BR /&gt;This works for me:&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;int main() {&lt;BR /&gt;char s[20];&lt;BR /&gt;sprintf( s, "\"hello\" \n");&lt;BR /&gt;printf("%s", s);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;...using B3901BA  B.11.11.16 HP C/ANSI C Developer's Bundle for HP-UX (S800)&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/STDIO.H&gt;</description>
      <pubDate>Wed, 22 Oct 2008 14:35:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sprintf-does-not-preserve-quotes-in-c-program/m-p/4292235#M688760</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-10-22T14:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: sprintf does not preserve quotes in c program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sprintf-does-not-preserve-quotes-in-c-program/m-p/4292236#M688761</link>
      <description>&lt;!--!*#--&gt;&amp;gt; system(s)&lt;BR /&gt;&lt;BR /&gt;Uh, what do you think this does?&lt;BR /&gt;&lt;BR /&gt;&amp;gt; this SHOULD work but does not:&lt;BR /&gt;&lt;BR /&gt;Depends on what you mean by "work".  If you&lt;BR /&gt;mean, "attempt to run the command, '"hello"',&lt;BR /&gt;then it works.  Lacking a complete example&lt;BR /&gt;program, I made one up.&lt;BR /&gt;&lt;BR /&gt;alp $ type sp.c&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;char s[133];&lt;BR /&gt;&lt;BR /&gt;sprintf(s,"\"hello\" \n");&lt;BR /&gt;system(s);&lt;BR /&gt;}&lt;BR /&gt;alp $ cc sp&lt;BR /&gt;alp $ link sp&lt;BR /&gt;alp $ run sp&lt;BR /&gt;%DCL-W-IVVERB, unrecognized command verb - check validity and spelling&lt;BR /&gt; \"hello"\&lt;BR /&gt;&lt;BR /&gt;The quotation marks are there.&lt;BR /&gt;&lt;BR /&gt;Or, on an HP-UX system;&lt;BR /&gt;&lt;BR /&gt;dy # cat sp.c&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;char s[133];&lt;BR /&gt;&lt;BR /&gt;sprintf(s,"\"hello\" \n");&lt;BR /&gt;system(s);&lt;BR /&gt;}&lt;BR /&gt;dy # cc -o sp sp.c&lt;BR /&gt;dy # ./sp&lt;BR /&gt;sh: hello:  not found.&lt;BR /&gt;&lt;BR /&gt;Much like a simple shell command:&lt;BR /&gt;&lt;BR /&gt;dy # sh "hello"&lt;BR /&gt;sh: hello:  not found.&lt;BR /&gt;&lt;BR /&gt;The shell eats the quotation marks.&lt;BR /&gt;&lt;BR /&gt;What, exactly, are you trying to do (or&lt;BR /&gt;expecting to happen)?&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Wed, 22 Oct 2008 15:15:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sprintf-does-not-preserve-quotes-in-c-program/m-p/4292236#M688761</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-10-22T15:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: sprintf does not preserve quotes in c program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sprintf-does-not-preserve-quotes-in-c-program/m-p/4292237#M688762</link>
      <description>I am trying to feed a command to the shell with quotes - like: echo "testing" &amp;gt; testfile...&lt;BR /&gt;&lt;BR /&gt;thanks</description>
      <pubDate>Wed, 22 Oct 2008 15:48:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sprintf-does-not-preserve-quotes-in-c-program/m-p/4292237#M688762</guid>
      <dc:creator>Dave Chamberlin</dc:creator>
      <dc:date>2008-10-22T15:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: sprintf does not preserve quotes in c program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sprintf-does-not-preserve-quotes-in-c-program/m-p/4292238#M688763</link>
      <description>Hi (again) Dave:&lt;BR /&gt;&lt;BR /&gt;Oh, if your are *actually* calling system() to pass the string you constructed, as shown in Steven's example [which I missed in your post because it didn't seem to make sense], then this example seems contrived.&lt;BR /&gt;&lt;BR /&gt;Substitute "date" for "hello" and the system() will return today's date.  The idea is that you are *executing* the command string using the Posix shell.  Your code isn't any different then:&lt;BR /&gt;&lt;BR /&gt;# sh -c "hello"&lt;BR /&gt;&lt;BR /&gt;See the manpages for 'system(3S)'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 22 Oct 2008 16:00:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sprintf-does-not-preserve-quotes-in-c-program/m-p/4292238#M688763</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-10-22T16:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: sprintf does not preserve quotes in c program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sprintf-does-not-preserve-quotes-in-c-program/m-p/4292239#M688764</link>
      <description>&lt;!--!*#--&gt;&amp;gt; I am trying to [...]&lt;BR /&gt;&lt;BR /&gt;Perhaps an actual failing test program would&lt;BR /&gt;be easier to diagnose than waving hands.&lt;BR /&gt;&lt;BR /&gt;First, you should probably lose the "\n".&lt;BR /&gt;&lt;BR /&gt;My HP-UX system is off again, but:&lt;BR /&gt;&lt;BR /&gt;alp $ type sp3.c&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;char s[133];&lt;BR /&gt;&lt;BR /&gt;sprintf(s,"pipe write sys$output \"hel  lo\" &amp;gt; sp3.out");&lt;BR /&gt;system(s);&lt;BR /&gt;}&lt;BR /&gt;alp $ cc sp3&lt;BR /&gt;alp $ link sp3&lt;BR /&gt;alp $ run sp3&lt;BR /&gt;alp $ type sp3.out&lt;BR /&gt;hel  lo&lt;BR /&gt;alp $&lt;BR /&gt;&lt;BR /&gt;I'd say that the quotation is working.&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Wed, 22 Oct 2008 16:21:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sprintf-does-not-preserve-quotes-in-c-program/m-p/4292239#M688764</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-10-22T16:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: sprintf does not preserve quotes in c program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sprintf-does-not-preserve-quotes-in-c-program/m-p/4292240#M688765</link>
      <description>Hi (again) Dave:&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;int main() {&lt;BR /&gt;char s[20];&lt;BR /&gt;sprintf( s, "\134"  "\042"  "hello"  "\134"  "\042"  "\n" );&lt;BR /&gt;system(s);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;...when compiled and run:&lt;BR /&gt;&lt;BR /&gt;sh: "hello":  not found.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/STDIO.H&gt;</description>
      <pubDate>Wed, 22 Oct 2008 16:49:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sprintf-does-not-preserve-quotes-in-c-program/m-p/4292240#M688765</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-10-22T16:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: sprintf does not preserve quotes in c program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sprintf-does-not-preserve-quotes-in-c-program/m-p/4292241#M688766</link>
      <description>&lt;!--!*#--&gt;dyi # cat sp3u.c&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;char s[133];&lt;BR /&gt;&lt;BR /&gt;sprintf(s,"echo \"hel  lo\" &amp;gt; sp3u.out");&lt;BR /&gt;system(s);&lt;BR /&gt;}&lt;BR /&gt;dyi # cc -o sp3u sp3u.c&lt;BR /&gt;dyi # ./sp3u&lt;BR /&gt;dyi # cat sp3u.out&lt;BR /&gt;hel  lo&lt;BR /&gt;dyi #&lt;BR /&gt;&lt;BR /&gt;Works on HP-UX, too.  (Without the quotation&lt;BR /&gt;marks, the spacing would be different, so&lt;BR /&gt;they're clearly getting used.)&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Perhaps an actual failing test program would&lt;BR /&gt;&amp;gt; be easier to diagnose than waving hands.&lt;BR /&gt;&lt;BR /&gt;Still true.  Working programs do seem to&lt;BR /&gt;work, however.&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Wed, 22 Oct 2008 20:10:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sprintf-does-not-preserve-quotes-in-c-program/m-p/4292241#M688766</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-10-22T20:10:03Z</dc:date>
    </item>
  </channel>
</rss>

