Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 May 2001 08:48:22 -0700
From:      Josef Grosch <jgrosch@mooseriver.com>
To:        Eric Boucher <eric_boucher60@yahoo.com>
Cc:        FreeBSD <freebsd-questions@FreeBSD.ORG>
Subject:   Re: C programming: how to execute command line?
Message-ID:  <20010518084822.B14015@mooseriver.com>
In-Reply-To: <20010518153811.38550.qmail@web9404.mail.yahoo.com>; from eric_boucher60@yahoo.com on Fri, May 18, 2001 at 08:38:11AM -0700
References:  <20010518153811.38550.qmail@web9404.mail.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, May 18, 2001 at 08:38:11AM -0700, Eric Boucher wrote:
> 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?


man fork
man execl
man execve

Josef

-- 
Josef Grosch           | Another day closer to a | FreeBSD 4.3
jgrosch@MooseRiver.com |   Micro$oft free world  | www.bafug.org


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010518084822.B14015>