How to issue a C SHELL command within a C program
George Turczynski
george at hls0.hls.oz
Fri Aug 17 10:02:40 AEST 1990
In article <25279.26c7fd35 at kuhub.cc.ukans.edu>, jian at kuhub.cc.ukans.edu writes:
> How can I issue a statment that executes a C SHELL command within a C program?
This works under SunOS 4.0.3 (and probably others):
system("/bin/csh -c \"<command>\"");
system() calls /bin/sh, which in this case starts a `csh' to perform
<command>. Note the \" around <command>. Here is a quick example:
main()
{
system("/bin/csh -c \"/bin/echo This command run by /bin/csh !\"");
exit(0);
}
--
| George P. J. Turczynski. |----------------------------------------------------
| Computer Systems Engineer. | ACSnet: george at highland.oz | I can't speak for the |
| Highland Logic Pty. Ltd. | Phone: +61 48 683490 | company, I can barely |
| Suite 1, 348-354 Argyle St | Fax: +61 48 683474 | speak for myself... |
| Moss Vale. NSW. Australia. 2577 |----------------------------------------------------
More information about the Comp.unix.questions
mailing list