Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 May 2001 08:38:11 -0700 (PDT)
From:      Eric Boucher <eric_boucher60@yahoo.com>
To:        FreeBSD <freebsd-questions@FreeBSD.ORG>
Subject:   C programming: how to execute command line?
Message-ID:  <20010518153811.38550.qmail@web9404.mail.yahoo.com>

next in thread | raw e-mail | index | archive | help
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




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