Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Executing a new process.

Posted on 2003-02-25
5
Medium Priority
?
189 Views
Last Modified: 2010-04-15
I having some difficutly passing command line arguement to my new process.

In my program I fork off a child process then I want it to call a new program so I use:
 execl("pathto/program.exe","program.exe","-commanline aregurments",NULL);

it doenst get the command line arguments correctly. Can someone tell me the proper syntax to do this correctly?
0
Comment
Question by:joele23
  • 2
  • 2
5 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 8019392
The 1st and 2nd parameter have to be identical, e.g.

execl("pathto/program.exe","pathto/program.exe","-commanline aregurments",NULL);

NOTE that the 1st argument will always be the program name with the path itself.

0
 
LVL 2

Author Comment

by:joele23
ID: 8019507
no im pretty sure that the second arguement only has to have the identical name of the executing program.

ie.

arg1 /pathto/this
arg2 this

see it starts to run only it doesnt get the command line arguments right
0
 
LVL 6

Accepted Solution

by:
gj62 earned 200 total points
ID: 8019645
I think your problem is in "- command arguements" - hopefully, that is just 1 arguement (no whitespace).  If not, it should be multiple parameters...

For examples, let's say you wanted to run a program called PROG with the arguements a b and c, as follows:

PROG -a b c

Your call should look like:

exec("PROG", "PROG", "-a", "b", "c");
0
 
LVL 6

Expert Comment

by:gj62
ID: 8019652
In other words, it should not be:

exec("PROG", "PROG", "-a b c");

At least according to the documentation for exec - not sure if they would be interpreted the same, but worth a try...

0
 
LVL 2

Author Comment

by:joele23
ID: 8019765
Ok that worked. I thouth I had tried that earlier but I think I had a leading whitespace character. Thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
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 recursion in the C programming language.
Suggested Courses

572 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