From owner-freebsd-questions Fri May 18 8:38:13 2001 Delivered-To: freebsd-questions@freebsd.org Received: from web9404.mail.yahoo.com (web9404.mail.yahoo.com [216.136.129.110]) by hub.freebsd.org (Postfix) with SMTP id 3E25437B424 for ; Fri, 18 May 2001 08:38:11 -0700 (PDT) (envelope-from eric_boucher60@yahoo.com) Message-ID: <20010518153811.38550.qmail@web9404.mail.yahoo.com> Received: from [207.164.184.163] by web9404.mail.yahoo.com; Fri, 18 May 2001 08:38:11 PDT Date: Fri, 18 May 2001 08:38:11 -0700 (PDT) From: Eric Boucher Subject: C programming: how to execute command line? To: FreeBSD MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hi everyone, I'm beggining programming in the C language and I want to know something: is it possible to simulate that a user have enter a command in a shell, and catch the exit code in a variable. Here is an exemple of what I want to do to be more explicit. Imagine that I want to catch the exit code if I'm in a shell prompt, I would write: $ ls -l; echo $? and the exit code will be displayed on the screen. So now, what I want to do is to catch this exit code in my C program. I think it will be something like this: int var; ... ... var = the_command_that_will_simulate_the_command_line ... ... So I will be able to use this variable in my program. I hope I make myself clear. Does somebody knows how to do this trick? Thank you Eric __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message