Solved

commands in the system function

Posted on 2003-10-23
4
355 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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to design, and implement simple interface 5 138
UPD maximums on Red Hat 6 120
An API detour question 7 93
Unable to start eclipse ? 17 153
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…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

808 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