Replace exec() calls with system calls and also use unlink_if_exists().