Updated code, it does not execute commands
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
void ExeclLS(int argc, char **argv) {
char *args[] = {"ls", "-aF", "/", 0};
char *env[] = { 0 };
printf("Rodando o bin/ls\n");
execve("bin/ls", args, env);
}
void ExeclTop(int argc, char **argv) {
char *args[] = {"top", "-aF", "/", 0};
char *env[] = { 0 };
printf("Rodando o bin/top\n");
execve("/usr/bin/top", args, env);
}
int main() {
int valorMenu;
printf("Digite o comando : 1 - ls , 2-top\n");
scanf("%i",&valorMenu);
if (valorMenu == 1){
printf("Rodando o bin/ls\n");
ExeclLS(0, NULL);
}else{
printf("Rodando o bin/Top\n");
ExeclTop(0,NULL);
}
perror("execve");
exit(1);
return 0;
}
Can anyone help me?