Performing arithmetics with execve from arguments passed by terminal

You don’t want to be passing 1 and 2 in the environment. The shell wants them as positional parameters. So you could do:

char *parmList[] = {"sh", "-c", "echo $0 $1 + $2 1 2", "sh", "1", "2", NULL};

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top