Link to home
Start Free TrialLog in
Avatar of jlm661
jlm661

asked on

c wrapper file

hello all! i feel like what i am trying to do is easy i am just unsure of how to do it.

what i want to do is create a c-wrapper file to run through a series of commands so that once the first program is complete pro/e will run. here are the commands i would type

1.) nsga2
2.) proewildfire trail2.txt

now with the nsga2 there are a lot of header files associated with it...do i have to include <> all of those?

thanks for all of your help!!!


SOLUTION
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America 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
This sounds like it would more appropriately be a shell script than a C program.
SOLUTION
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
SOLUTION
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
ASKER CERTIFIED SOLUTION
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
Avatar of jlm661
jlm661

ASKER

okay so i have tried to create a simple c program...it compiles and runs but there is no output...for example:

/*this C-wrapper file will execute first the nsga2 executable file and then run pro/e using the trail.txt file*/

#include <stdlib.h>
#include <stdio.h>

main()
{
  printf("Files in Directory are:\n");
             execl("/home/edog.1/jlm661/nsga/GA/","ls", "-l",0);
  //printf("The following output describes the NSGA optimization process:\n");
             //execl("/home/edog.1/jlm661/nsga/GA/","nsga2", 0);
  //printf("Pro/E will now run using the trail.txt file:n");
             //execl("/home/edog.1/", "proewildfire trail.txt", 0);
}

i am just trying to show the list of the files contained in my folder, but when i run the executable nothing but the line i printed comes up. what am i donig wrong? i probably look like a newbie but i am so bear with me :)
Hi jlm661,

execl() is NOT the same as system().  system() spawns another task and executes the command string that you pass to it.  execl() replaces the current task with whatever the execl() is supposed to do.

Change the calls to execl() to system().  You'll also have to build the command string into a single string.

Kent
Avatar of jlm661

ASKER

thanks kent! you rock!!!! it works! i might have some more quesitons later but right now i am good...THANK YOU!!

jess