?
Solved

Executing a new process.

Posted on 2003-02-25
5
Medium Priority
?
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
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.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

764 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