Solved

commands in the system function

Posted on 2003-10-23
4
354 Views
Last Modified: 2010-04-15
hi, can anybody explain the following line:

system("start cmd.exe /c %s %s -Pipe_Mode:%s %s\n", environmental variable name,filename,name of the named pipe")

i didn't understand what does these /c %s etc here?

or give me a link where i find more about these commands.Thanks in advance.

rukmani.
0
Comment
Question by:rukks
  • 3
4 Comments
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9605494
this is not a valid syntax
>system("start cmd.exe /c %s %s -Pipe_Mode:%s %s\n", environmental variable name,filename,name of the named pipe")

actual proto type is
       int system (const char * string);
it cannot accept more than one argument
Where did you get it from ?

you need to form a single string from all these things (sprintf) and then pass that single string to system

the person who gave it to you perhaps meant that form a command from all these components %s specifies string format specifier
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9605513
/c is an argument to start cmd.exe
to make the above command work, you need a string like

"start cmd.exe /c aa bb -Pipe_Mode:cc dd"
where
aa : environmental variable
bb :  name
cc  : filename
dd : name of the named pipe

such string can be obtained using sprintf statement

the right way to invoke this command would be
sprintf ( command, "start cmd.exe /c %s %s -Pipe_Mode:%s %s", ev, n, fn, np );
system (command);

where
ev holds  : environmental variable
n holds :  name
fn holds  : filename
np holds : name of the named pipe
0
 

Author Comment

by:rukks
ID: 9605539
yes, u r right.
The actual code is as follows:
 
sprintf(cmdLine, "start cmd.exe /c %s %s -Pipe_Mode:%s %s\n",
                       dat_cmd, geo_file, in_pipe_name, out_pipe_name);
      signal = system(cmdLine);


when i run this code, the command window only momentrarily flashes. system returned zero. I am using named pipes for connecting 2 processes.in_pipe_name, out_pipe_name are the name of these pipes.geo_file contains the file name.
0
 
LVL 45

Accepted Solution

by:
sunnycoder earned 50 total points
ID: 9605550
ok then it is all fine...
/c is argument to the executable and %s is string format specifier as in printf

any more questions ?
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question