home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / question / 10582 < prev    next >
Encoding:
Text File  |  1992-08-31  |  1.6 KB  |  43 lines

  1. Xref: sparky comp.unix.questions:10582 comp.lang.c:13036
  2. Newsgroups: comp.unix.questions,comp.lang.c
  3. Path: sparky!uunet!newsgate.watson.ibm.com!yktnews!admin!curt
  4. From: curt@watson.ibm.com (Curt McDowell)
  5. Subject: Re: 'system' call uses 'sh'... Can I change this??
  6. Sender: news@watson.ibm.com (NNTP News Poster)
  7. Message-ID: <1992Aug31.221803.23282@watson.ibm.com>
  8. Date: Mon, 31 Aug 1992 22:18:03 GMT
  9. Distribution: comp
  10. Lines: 26
  11. Disclaimer: This posting represents the poster's views, not necessarily those of IBM
  12. References:  <1992Aug31.203936.20409@infonode.ingr.com>
  13. Nntp-Posting-Host: gorby.watson.ibm.com
  14. Organization: IBM T.J. Watson Research Center
  15. Keywords: system sh
  16.  
  17. In article <1992Aug31.203936.20409@infonode.ingr.com>, henders@infonode.ingr.com (Greg Henderson) writes:
  18. > Hopefully someone has run across a way to work around this...  
  19. ...
  20. > Does anyone know a way to get the system call to use  a different shell
  21. > Greg Henderson   henders@infonode.ingr.com   ...uunet!ingr!infonode!henders
  22.  
  23. There's no way to do it directly.  /bin/sh is hardwired into the system()
  24. routine.  Your best bet is just to live with /bin/sh, but if you must, you
  25. can get around it indirectly (and inefficiently) like this:
  26.  
  27. main()
  28. {
  29.         system("exec /bin/ksh -c 'YOUR COMMAND HERE'");
  30. }
  31.  
  32. Replace YOUR COMMAND HERE with whatever command you would have originally
  33. wanted to run under ksh.  The "exec" causes /bin/sh to replace itself with
  34. /bin/ksh right after it starts up.
  35.  
  36. For the C shell, use -fc instead of -c, so it doesn't read .cshrc (very
  37. important).
  38.  
  39. --
  40. Curt McDowell
  41. IBM T. J. Watson Research Center
  42.