Doubt regarding "Build a string (with sprintf) and then use

Guest
Hi,

If I build a string by using sprintf, the string will have double
quotes with it.
If I have to use double quotes within the system function it has to be
this way : system("mailx -s \"subject title\" -c \"emaiid@xyz.com\"
toemail@xyz.com ")

If I used concat to convert the string to a symbol and there by get
rid of the double quotes, it places \ in front of @ , . etc .....

Using the pattern matching functions doesnt work as they return string
values .....
 
eesra.m@gmail.com wrote:
Hi,

If I build a string by using sprintf, the string will have double
quotes with it.
If I have to use double quotes within the system function it has to be
this way : system("mailx -s \"subject title\" -c \"emaiid@xyz.com\"
toemail@xyz.com ")

If I used concat to convert the string to a symbol and there by get
rid of the double quotes, it places \ in front of @ , . etc .....

Using the pattern matching functions doesnt work as they return string
values .....
Build the complete string, including the mailx command.

system(STRING)
 
Marc Heise wrote, on 03/17/09 08:34:
eesra.m@gmail.com wrote:
Hi,

If I build a string by using sprintf, the string will have double
quotes with it.
If I have to use double quotes within the system function it has to be
this way : system("mailx -s \"subject title\" -c \"emaiid@xyz.com\"
toemail@xyz.com ")

If I used concat to convert the string to a symbol and there by get
rid of the double quotes, it places \ in front of @ , . etc .....

Using the pattern matching functions doesnt work as they return string
values .....

Build the complete string, including the mailx command.

system(STRING)
To concur with what Marc says, you really don't need to worry about the escaped
quotes you see when you show the variable in the CIW - the quotes around the
string are just to show that it's a string, and any embedded quotes will be
escaped during the printing. You don't need to use pattern matching stuff. I
think you're over-complicating things. For example, if I do:

myString="\""
strlen(myString) => 1
printf("%s\n" myString)

will show:

"

So you can do:

subject="my subject"
cc="emaiid@xyz.com"
recipient="toemail@xyz.com"
sprintf(command "mailx -s \"%s\" -c \"%s\" \"%s\"" subject cc recipient)
system(command)

Regards,

Andrew.
 

Welcome to EDABoard.com

Sponsor

Back
Top