Link to home
Start Free TrialLog in
Avatar of rukks
rukks

asked on

commands in the system function

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.
Avatar of sunnycoder
sunnycoder
Flag of India image

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
/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
Avatar of rukks
rukks

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial