- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: system() with sprintf()
Operating System - Linux
1753378
Members
5002
Online
108792
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2006 01:02 AM
06-30-2006 01:02 AM
system() with sprintf()
Hi All,
I am experiencing a small problem with single quotes in a awk script
If I use the sprintf cmd shown below it returns the following error mesg
selcmd1=sprintf("%s","echo select A_NUM=nullif\(A_NUM,\\\" \\\"\) R_DT=date\('2006/06/06'\) "\\\\ngo | " opt)
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
Msg 257, Level 16, State 0:
ASA Error -157: Cannot convert 55 to a date
I know it is doing an mathematical sum.
Code:
function select_tablename(selcmd1,dc)
{
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
if (dc = system(selcmd1) != 0)
{
PLogmsg(2, "Failed ")
}
close(selcmd1)
system(selcmd1)
}
Instead of me doing a date conversion , how can I use with single quotes in the R_DT=('2006/06/06 00:00:00')
Many Thanks
Chris
I am experiencing a small problem with single quotes in a awk script
If I use the sprintf cmd shown below it returns the following error mesg
selcmd1=sprintf("%s","echo select A_NUM=nullif\(A_NUM,\\\" \\\"\) R_DT=date\('2006/06/06'\) "\\\\ngo | " opt)
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
Msg 257, Level 16, State 0:
ASA Error -157: Cannot convert 55 to a date
I know it is doing an mathematical sum.
Code:
function select_tablename(selcmd1,dc)
{
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
if (dc = system(selcmd1) != 0)
{
PLogmsg(2, "Failed ")
}
close(selcmd1)
system(selcmd1)
}
Instead of me doing a date conversion , how can I use with single quotes in the R_DT=('2006/06/06 00:00:00')
Many Thanks
Chris
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2006 10:12 PM
07-02-2006 10:12 PM
Re: system() with sprintf()
Hi,
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.
# Stanbdalone
#!/usr/bin/awk
function select_tablename ....
Enbedded:
#!/usr/bin/ksh
...
awk 'function select_tablename ...'
...
In the later case, I usually call
awk -v sq="'" -v dq='"' '...'
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.
mfG Peter
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.
# Stanbdalone
#!/usr/bin/awk
function select_tablename ....
Enbedded:
#!/usr/bin/ksh
...
awk 'function select_tablename ...'
...
In the later case, I usually call
awk -v sq="'" -v dq='"' '...'
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.
mfG Peter
The Universe is a pretty big place,
it's bigger than anything anyone has ever dreamed of before.
So if it's just us, seems like an awful waste of space, right?
Jodie Foster in "Contact"
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP