1

I want to see only football in the stdout. And if instead of using echo I use a nonexistant command, then Id like it to be redirected to stderr. Im doubting if its doable.

int main(int argc, char *argv[]) {
        char *tab[] = {"echo", "football", "2> /dev/null", NULL};

        char test [strlen("echo") + strlen( "/bin/" ) +1];
        strcpy(test, "/bin/");
        strcat(test, "echo");
        execve(test, tab, NULL);
    
        return 0;
}

I get football 2> /dev/null but I want only to see football.

user3386109
  • 34,287
  • 7
  • 49
  • 68
LIsa
  • 133
  • 8

0 Answers0