Executing another program from C program

Executing another program from C program

Post by Nelson Miguel Viei » Fri, 24 Feb 1995 07:29:33



        I'm new to C and UNIX :)  How would I call another program from
within a C program

Thanks

--

2nd Year CompSci Honours       | WEB page:            
University of Manitoba         |    ftp://ftp.cc.umanitoba.ca
Winnipeg, Manitoba, Canada     |          /pub/umvieir2/index.html

 
 
 

Executing another program from C program

Post by James Knowle » Fri, 24 Feb 1995 22:21:32




   Newsgroups: comp.unix.programmer
   Date: 22 Feb 1995 22:29:33 GMT
   Organization: The University of Manitoba

           I'm new to C and UNIX :)  How would I call another program from
   within a C program

   Thanks

   --

   2nd Year CompSci Honours       | WEB page:            
   University of Manitoba         |    ftp://ftp.cc.umanitoba.ca
   Winnipeg, Manitoba, Canada     |          /pub/umvieir2/index.html

--------------------
    check out  the  execlxxx   series (execl, with variety of endings),
    or the system()  call.  read up on the specifics before trying.
--------------------
  disclaimer:----these are only MY opinions, and, anyway,
                 they're only my OPINIONS...
             ----

 
 
 

Executing another program from C program

Post by Brian B. Rodenbo » Sun, 26 Feb 1995 09:14:13




Quote:

>    I'm new to C and UNIX :)  How would I call another program from
>within a C program

>Thanks

If you are referring to calling another executable program, the usual ways
are to use the system call (simple) or one of the family of exec calls.
There are a number of these, you have to choose the one that fits best. An
exec replaces the calling program entirely, so it is usually used in
conjunction with a fork call, with the child process doing the actual
exec. For most applications, system works pretty well. Check the man pages
on the various calls.

Brian Rodenborn
McDonnell-Douglas Aerospace


 
 
 

Executing another program from C program

Post by Brian B. Rodenbo » Wed, 08 Mar 1995 03:15:22




Quote:

>    I'm new to C and UNIX :)  How would I call another program from
>within a C program

Check out system and the exec family. These are the normal ways of running
another (executable) program from within a C program. If you use one of the
exec calls, it replaces the calling program, so it is usually used with an
fork to spawn off a child process to do the exec.

Brian Rodenborn
McDonnell-Douglas Aerospace


 
 
 

Executing another program from C program

Post by Ken Shephe » Mon, 22 May 1995 04:00:00




:    Newsgroups: comp.unix.programmer
:    Date: 22 Feb 1995 22:29:33 GMT
:    Organization: The University of Manitoba

:          I'm new to C and UNIX :)  How would I call another program from
:    within a C program

You can use the system() function...

    int rc;
    rc = system("ls -laxpi");

Each command you can call can define its own set of return codes.
If calling another c language program, it will set its return
code via the exit() function.

--
-------------------------------------------------------------------------------
Ken Shepherd                              __  __     ____  ___       ___ ____

                                        /   / \  / / / / /__ /  \/ /___  /
-------------------------------------------------------------------------------

 
 
 

Executing another program from C program

Post by Jose Barr » Tue, 23 May 1995 04:00:00





: :    Newsgroups: comp.unix.programmer
: :    Date: 22 Feb 1995 22:29:33 GMT
: :    Organization: The University of Manitoba

: :        I'm new to C and UNIX :)  How would I call another program from
: :    within a C program

: You can use the system() function...

:     int rc;
:     rc = system("ls -laxpi");

: Each command you can call can define its own set of return codes.
: If calling another c language program, it will set its return
: code via the exit() function.

: [.sig deleted]

I guess, in this day and age, most people would recommend 'popen' instead
of 'system' .... thus try 'man popen'

Cheers!

Jose

 
 
 

1. Executing a program (shell script) from within a c program

I need to execute multiple shell scripts from a C program. I need to be
able to set the user and group IDs as well. Furthermore, I need to be able
to detach those processes from the main executable (my C program) so that
I can call multiple other programs concurrently, without the main program
having to wait.

Can anyone tell me how I can accomplish this--or what book I should
consult? I am not a programmer and the man pages are way too cryptic.

--
__      ||  _      |
_/ __ _ |+-(_ __ _ |_  _
/__\ (_)|| __) /(_||_)(_)

2. Need help with default password

3. Executing programs within a program

4. Multimon patches: what now?

5. Executing a program with in a program.

6. setsid() and setgrp: operation not permitted??

7. "Mary had a neat program...neat program...neat program...

8. ftp protocol question

9. Executing a program's output. How?

10. Problem with executing cgi programs from the Netscape Enterprise Server

11. Executing remote programs from a ksh script

12. having programs execute at login time

13. Automatically executing programs in netscape