Solved

commands in the system function

Posted on 2003-10-23
4
352 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
Comment Utility
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
Comment Utility
/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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now