<?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 system() with sprintf() in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/system-with-sprintf/m-p/3815649#M100171</link>
    <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;I am experiencing a small problem with single quotes in a awk script&lt;BR /&gt;&lt;BR /&gt;If I use the sprintf cmd shown below it returns the following error mesg&lt;BR /&gt;&lt;BR /&gt;selcmd1=sprintf("%s","echo select A_NUM=nullif\(A_NUM,\\\" \\\"\) R_DT=date\('2006/06/06'\) "\\\\ngo | " opt)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; select A_NUM=nullif\(A_NUM,\" \"\) from CE.CDR_DRMS where R_DT=date\(2006/06/06\) and A_1=0 and A_2=1 and A_3=2 and A_4=3 and A_5=1 and A_6=1 and A_7=8 and A_8=8 and A_9=6 and A_10=isnull\(5,\"\"\) \\ngo | /sybase_oc/OCS-12_0/bin/isql -UDBA -PSQL -Sdrms_iq CHATAA&lt;BR /&gt;Msg 257, Level 16, State 0:&lt;BR /&gt;ASA Error -157: Cannot convert 55 to a date&lt;BR /&gt;&lt;BR /&gt;I know it is doing an mathematical sum.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Code:&lt;BR /&gt;&lt;BR /&gt;function select_tablename(selcmd1,dc)&lt;BR /&gt;{&lt;BR /&gt;selcmd1="echo select A_NUM=nullif\\(A_NUM,\\\" \\\"\\) from CE.CDR_DRMS where R_DT=date\\('2006/06/06'\\) and A_1="Dig1" and A_2="Dig2" and A_3="Dig3" and A_4="Dig4" and A_5="Dig5" and A_6="Dig6" and A_7="Dig7" and A_8="Dig8" and A_9="Dig9" and A_10=isnull\("Dig10",\\\"\\\"\) \\\\ngo | " opt  &lt;BR /&gt;               if (dc = system(selcmd1) != 0)&lt;BR /&gt;                {&lt;BR /&gt;                       PLogmsg(2, "Failed ")&lt;BR /&gt;                }&lt;BR /&gt;                close(selcmd1)&lt;BR /&gt;                system(selcmd1)&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Instead of me doing a date conversion , how can I use with single quotes in the R_DT=('2006/06/06 00:00:00')&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Many Thanks  &lt;BR /&gt;Chris</description>
    <pubDate>Fri, 30 Jun 2006 08:02:17 GMT</pubDate>
    <dc:creator>Chris Frangandonis</dc:creator>
    <dc:date>2006-06-30T08:02:17Z</dc:date>
    <item>
      <title>system() with sprintf()</title>
      <link>https://community.hpe.com/t5/operating-system-linux/system-with-sprintf/m-p/3815649#M100171</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;I am experiencing a small problem with single quotes in a awk script&lt;BR /&gt;&lt;BR /&gt;If I use the sprintf cmd shown below it returns the following error mesg&lt;BR /&gt;&lt;BR /&gt;selcmd1=sprintf("%s","echo select A_NUM=nullif\(A_NUM,\\\" \\\"\) R_DT=date\('2006/06/06'\) "\\\\ngo | " opt)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; select A_NUM=nullif\(A_NUM,\" \"\) from CE.CDR_DRMS where R_DT=date\(2006/06/06\) and A_1=0 and A_2=1 and A_3=2 and A_4=3 and A_5=1 and A_6=1 and A_7=8 and A_8=8 and A_9=6 and A_10=isnull\(5,\"\"\) \\ngo | /sybase_oc/OCS-12_0/bin/isql -UDBA -PSQL -Sdrms_iq CHATAA&lt;BR /&gt;Msg 257, Level 16, State 0:&lt;BR /&gt;ASA Error -157: Cannot convert 55 to a date&lt;BR /&gt;&lt;BR /&gt;I know it is doing an mathematical sum.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Code:&lt;BR /&gt;&lt;BR /&gt;function select_tablename(selcmd1,dc)&lt;BR /&gt;{&lt;BR /&gt;selcmd1="echo select A_NUM=nullif\\(A_NUM,\\\" \\\"\\) from CE.CDR_DRMS where R_DT=date\\('2006/06/06'\\) and A_1="Dig1" and A_2="Dig2" and A_3="Dig3" and A_4="Dig4" and A_5="Dig5" and A_6="Dig6" and A_7="Dig7" and A_8="Dig8" and A_9="Dig9" and A_10=isnull\("Dig10",\\\"\\\"\) \\\\ngo | " opt  &lt;BR /&gt;               if (dc = system(selcmd1) != 0)&lt;BR /&gt;                {&lt;BR /&gt;                       PLogmsg(2, "Failed ")&lt;BR /&gt;                }&lt;BR /&gt;                close(selcmd1)&lt;BR /&gt;                system(selcmd1)&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Instead of me doing a date conversion , how can I use with single quotes in the R_DT=('2006/06/06 00:00:00')&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Many Thanks  &lt;BR /&gt;Chris</description>
      <pubDate>Fri, 30 Jun 2006 08:02:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/system-with-sprintf/m-p/3815649#M100171</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2006-06-30T08:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: system() with sprintf()</title>
      <link>https://community.hpe.com/t5/operating-system-linux/system-with-sprintf/m-p/3815650#M100172</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;since it seems tat you need both single- and doublequotes in your awk-script, we must know, if your script is (I call it so) standalone or embedded in another shellscript.&lt;BR /&gt;# Stanbdalone&lt;BR /&gt;#!/usr/bin/awk&lt;BR /&gt;function select_tablename ....&lt;BR /&gt;&lt;BR /&gt;Enbedded:&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;...&lt;BR /&gt;awk 'function select_tablename ...'&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;In the later case, I usually call&lt;BR /&gt;&lt;BR /&gt;awk -v sq="'" -v dq='"' '...'&lt;BR /&gt;&lt;BR /&gt;and use the variables sq for single quotes and dq for double quotes. I find the code is more readable, when you know that a double quote belongs solely to your program code.&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Mon, 03 Jul 2006 05:12:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/system-with-sprintf/m-p/3815650#M100172</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-07-03T05:12:55Z</dc:date>
    </item>
  </channel>
</rss>

