Xref: utzoo comp.unix.questions:30903 comp.lang.c:38899 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!apple!well!ron From: ron@well.sf.ca.us (Ronald Hayden) Newsgroups: comp.unix.questions,comp.lang.c Subject: Re: UNIX commands in C Message-ID: <24527@well.sf.ca.us> Date: 1 May 91 05:07:42 GMT References: <1991Apr28.153127.24926@jack.sns.com> Lines: 27 jtanner@jack.sns.com (Jason Tanner) writes: > I have been programming C for a while on IBM compats. using Turbo-C >from Borland. Now I would like to move up to programing C in the UNIX >enviroment. I know how to use all the regular C commands but I would like >to know how to use UNIX commands from within a C program. For example >to have the option to show who is online from within a program. I dont >want this done with a shell escape I want it to be an potion like from a >menu/list. > Thank you in advance. Please Email or post all replies. >-- There are actually several ways to do this (check out the book C Programming In a UNIX Environment for a complete discussion), but for a simple command such as "who", you can simply: #include main () { printf("\nTesting the UNIX 'who' command --\n"); system("who"); printf("\nDone.\n"); exit(1); }