home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.questions:10582 comp.lang.c:13036
- Newsgroups: comp.unix.questions,comp.lang.c
- Path: sparky!uunet!newsgate.watson.ibm.com!yktnews!admin!curt
- From: curt@watson.ibm.com (Curt McDowell)
- Subject: Re: 'system' call uses 'sh'... Can I change this??
- Sender: news@watson.ibm.com (NNTP News Poster)
- Message-ID: <1992Aug31.221803.23282@watson.ibm.com>
- Date: Mon, 31 Aug 1992 22:18:03 GMT
- Distribution: comp
- Lines: 26
- Disclaimer: This posting represents the poster's views, not necessarily those of IBM
- References: <1992Aug31.203936.20409@infonode.ingr.com>
- Nntp-Posting-Host: gorby.watson.ibm.com
- Organization: IBM T.J. Watson Research Center
- Keywords: system sh
-
- In article <1992Aug31.203936.20409@infonode.ingr.com>, henders@infonode.ingr.com (Greg Henderson) writes:
- > Hopefully someone has run across a way to work around this...
- ...
- > Does anyone know a way to get the system call to use a different shell
- >
- > Greg Henderson henders@infonode.ingr.com ...uunet!ingr!infonode!henders
-
- There's no way to do it directly. /bin/sh is hardwired into the system()
- routine. Your best bet is just to live with /bin/sh, but if you must, you
- can get around it indirectly (and inefficiently) like this:
-
- main()
- {
- system("exec /bin/ksh -c 'YOUR COMMAND HERE'");
- }
-
- Replace YOUR COMMAND HERE with whatever command you would have originally
- wanted to run under ksh. The "exec" causes /bin/sh to replace itself with
- /bin/ksh right after it starts up.
-
- For the C shell, use -fc instead of -c, so it doesn't read .cshrc (very
- important).
-
- --
- Curt McDowell
- IBM T. J. Watson Research Center
-