🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #5719

Re: het linux commando " ls -al " opvragen vanuit c code

#5719
From: Jo Vermeulen
Date: Thu, 06 Mar 2003 16:33
44 lines
2097 bytes
dA_CoSMiC wrote:

> yow
> 
> had een klein vraagje waar ik al een tijdje mee verveeld zit
> hoe kan je in c code het linux commando " ls -al " opvragen van de actieve
> directory?
> voor alle duidelijkheid, ik programmeer alles ook in linux
>

Je kan zoiets doen via de system() functie.

Dit programma zou het moeten doen:

int main()
{
    system("ls -al");
}

Op http://www.acm.uiuc.edu/webmonkeys/book/c_guide/2.13.html#system staat 
het volgende:

***
2.13.4.5 system

Declaration:

    int system(const char *string);

The command specified by string is passed to the host environment to be 
executed by the command processor. A null pointer can be used to inquire 
whether or not the command processor exists.

If string is a null pointer and the command processor exists, then zero is 
returned. All other return values are implementation-defined. 
***

Mvg,

-- 
Jo Vermeulen
Student Computer Science at the tUL
email: jo@lumumba.luc.ac.be
www: http://lumumba.luc.ac.be/jo
Technical Details
Message-ID: <b47t8p$m1s$1@nl-news.euro.net>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-01!sn-xit-08!supernews.com!easynet-quince!easynet.net!mephistopheles.news.clara.net!news.clara.net!news2.euro.net!nl-news.euro.net!not-for-mail
References: <b47o7l$ic4$1@reader11.wxs.nl>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fcea4,27f9cd08e020e305
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2003-03-06 08:33:34 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-01!sn-xit-08!supernews.com!easynet-quince!easynet.net!mephistopheles.news.clara.net!news.clara.net!news2.euro.net!nl-news.euro.net!not-for-mail
From: Jo Vermeulen <jo@lumumba.luc.ac.be>
Newsgroups: be.comp.programming
Subject: Re: het linux commando " ls -al " opvragen vanuit c code
Date: Thu, 06 Mar 2003 17:33:37 +0100
Organization: tUL
Lines: 44
Message-ID: <b47t8p$m1s$1@nl-news.euro.net>
References: <b47o7l$ic4$1@reader11.wxs.nl>
Reply-To: jo@lumumba.luc.ac.be
NNTP-Posting-Host: u212-239-187-157.adsl.pi.be
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7Bit
X-Trace: nl-news.euro.net 1046968409 22588 212.239.187.157 (6 Mar 2003 16:33:29 GMT)
X-Complaints-To: usenet@nl-news.euro.net
NNTP-Posting-Date: Thu, 6 Mar 2003 16:33:29 +0000 (UTC)
User-Agent: KNode/0.7.1