home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!Germany.EU.net!nixpbe!uranium!uranium!not-for-mail
- From: Josef Moellers <mollers.pad@sni.de>
- Newsgroups: comp.unix.programmer
- Subject: Re: How to execute unix commands from a c-program
- Date: 6 Nov 1992 12:31:44 +0100
- Organization: Siemens Nixdorf Informationssysteme AG, Paderborn, Germany
- Lines: 56
- Sender: josef@uranium.sto.pdb.sni.de
- Message-ID: <1ddl30INNet2@uranium.sto.pdb.sni.de>
- References: <1992Nov4.153029.21837@cs.ruu.nl> <1992Nov4.163532.8801@cbfsb.cb.att.com>
-
- In <1992Nov4.163532.8801@cbfsb.cb.att.com> nll@cbnewsb.cb.att.com (neal.l.leitner) writes:
-
- >From article <1992Nov4.153029.21837@cs.ruu.nl>, by hpverwei@cs.ruu.nl (Dick Verweij):
- >> See subject,
- >>
- >> --
- >> DICK H.P. VERWEIJ
- >>
- >> --------------------------------------------------------------------------------
- >> D:-) I:-) C:-) K:-) email : hpverwei@cs.ruu.nl
- >main()
- >{
- > .
- > .
- > .
- > system("ls -l");
- >}
-
- >or
-
- >main()
- >{
- > char mystring[10];
- > .
- > .
- > .
- > strcpy(mystring,"ls -l");
- > system(mystring);
- >}
-
- or
- main()
- {
- .
- .
- .
- switch (fork())
- {
- case 0: /* child */
- execlp("ls", "ls", "-l", NULL);
- perror("ls");
- exit(1);
- case -1: /* Error */
- perror("fork");
- break;
- default: /* parent */
- /* You can wait() here */
- break;
- }
- }
-
- This saves the overhead of firing up Your shell, as done by system()!
- --
- | Josef Moellers | c/o Siemens Nixdorf Informationssysteme AG |
- | USA: mollers.pad@sni-usa.com | Abt. STO-XS 113 | Riemekestrasse |
- | !USA: mollers.pad@sni.de | Phone: (+49) 5251 835124 | D-4790 Paderborn |
-