Considering white spaces in search patterns

R

royzlife

Hi,

I am running a command like the one given below through a process:

abc d:\myfolder\xyz_%s.*.log . -> now the %s puts a string which may
or may not contain white spaces...
e,g abc d:\myfolder\xyz_EARTH LIFE.*.log
how should i confirm that that the entire string should be taken into
consideration along with the white space in between to run the command
abc on the file xyz_EARTH LIFE.123.log?

Please help....
 
J

Jack Klein

Hi,

I am running a command like the one given below through a process:

What's a process? Do you mean a C program? Are you passing a string
to the system() function?
abc d:\myfolder\xyz_%s.*.log . -> now the %s puts a string which may
or may not contain white spaces...
e,g abc d:\myfolder\xyz_EARTH LIFE.*.log
how should i confirm that that the entire string should be taken into
consideration along with the white space in between to run the command
abc on the file xyz_EARTH LIFE.123.log?

Please help....

If you are using the standard C function system(), it depends on your
system's command interpreter or shell, as this is what will actually
parse the string.

If a file name that you pass to the system function might contain
spaces, your shell might need you to quote it. So instead of:

sprintf(buffer, "abc %s", file_name_that_might_contain_spaces);

....you might try:

sprintf(buffer, "abc \"%s\", file_name_that_might_contain_spaces);

If that does not work for you, or you are using some method other than
the standard C library system() function, post in a group that
supports your particular platform.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
 
R

Richard Bos

I am running a command like the one given below through a process:

abc d:\myfolder\xyz_%s.*.log . -> now the %s puts a string which may
or may not contain white spaces...
e,g abc d:\myfolder\xyz_EARTH LIFE.*.log
how should i confirm that that the entire string should be taken into
consideration along with the white space in between to run the command
abc on the file xyz_EARTH LIFE.123.log?

What on earth made you conceive that this could possible be a C
question? How command lines are parsed is up to the shell, not up to any
individual C program. IOW: read your shell's manual, or ask in a
newsgroup which handles MS Windows command.com.

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top