daca vrei sa rulezi un "ls -la" se poate in doua feluri
1) system
if (system("ls -la"))
        printf("comanda a eshuat\n");
else
        printf("succes");

2) varianta 'grea'
extern char **environ;
int status;
int PID = fork();
if (PID>0) {
        char **comanda = malloc (sizeof(char*)*3);
        comanda[0] = "ls";
        comanda[1] = "-la";
        comanda[2] = NULL;
        execve ("/bin/ls", comanda, environ);
        printf ("Eroare exec");
        exit(1);
}
else 
        if (PID<0) {
                printf ("eroare fork");
                exit(1);
        }
wait(&status);


man fork, man 2 wait si man execve sunt edificatoare.


On Monday 24 June 2002 05:19 pm, Serghei Amelian wrote:
> On Monday 24 June 2002 05:13 pm, Dorin Lazar wrote:
> > On Monday 24 June 2002 05:13 pm, Serghei Amelian wrote:
> > > Cum verific daca system("comanda &") s-a executat corect?
> > > Am observat ca returneaza 0 chiar daca comanda respectiva nu exista...
> >
> > Fara &...
> > Daca vrei sa mearga in fundal... Foloseshte fork+execve
>
> Sunt cam paralel cu apelurile de sistem. Poti sa-mi dai un exemplu simplu?

---
Pentru dezabonare, trimiteti mail la 
[EMAIL PROTECTED] cu subiectul 'unsubscribe rlug'.
REGULI, arhive si alte informatii: http://www.lug.ro/mlist/


Raspunde prin e-mail lui