home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / programm / 5168 < prev    next >
Encoding:
Text File  |  1992-11-05  |  1.4 KB  |  56 lines

  1. Newsgroups: comp.unix.programmer
  2. Path: sparky!uunet!pipex!warwick!coventry!champion
  3. From: champion@cch.coventry.ac.uk (Alun)
  4. Subject: Re: How to execute unix commands from a c-program
  5. Message-ID: <Bx8rJD.34D@cck.coventry.ac.uk>
  6. Sender: news@cck.coventry.ac.uk (news user)
  7. Nntp-Posting-Host: cc_sysh
  8. Organization: Coventry University, Coventry, UK.
  9. References: <1992Nov4.153029.21837@cs.ruu.nl> <1992Nov4.163532.8801@cbfsb.cb.att.com>
  10. Date: Thu, 5 Nov 1992 11:49:49 GMT
  11. Lines: 43
  12.  
  13. In article <1992Nov4.163532.8801@cbfsb.cb.att.com> nll@cbnewsb.cb.att.com (neal.l.leitner) writes:
  14. ~From article <1992Nov4.153029.21837@cs.ruu.nl>, by hpverwei@cs.ruu.nl (Dick Verweij):
  15. ~> See subject,
  16. ~> 
  17. ~> -- 
  18. ~> DICK H.P. VERWEIJ
  19. ~> 
  20. ~> --------------------------------------------------------------------------------
  21. ~> D:-) I:-) C:-) K:-) email : hpverwei@cs.ruu.nl 
  22. ~main()
  23. ~{
  24. ~      .
  25. ~      .
  26. ~      .
  27. ~      system("ls -l");
  28. ~}
  29. ~
  30. ~or
  31. ~
  32. ~main()
  33. ~{
  34. ~      char mystring[10];
  35. ~      .
  36. ~      .
  37. ~      .
  38. ~      strcpy(mystring,"ls -l");
  39. ~      system(mystring);
  40. ~}
  41.  
  42. what about
  43. main()
  44. {
  45.     execl("/bin/ls", "ls", "-l", 0);
  46. }
  47.     
  48. I personally don't like the system call as it uses /bin/sh to run the program.
  49. There also is a question about the security of system() with setuid programs.
  50.  
  51.     -Alun
  52.   
  53. -- 
  54. A.Champion                |  That's an interesting point, in the sense of
  55. (champion@uk.ac.cov.cck)  |    being very not interesting at all. - The Liar
  56.