jacob navia said:
[...]
[attribution lost]
Those reasons would make it fail within the command shell also!
If you have the wrong permissions, for instance, it should
not work in the command shell!!!
What I want to say is that IF the command works within a
command shell, it MUST work within the system() function,
unless the user or the program is impersonating somebody else.
Not correct. I can think of a number of other reasons why a system()
command might fail even if the same command string works in a command
shell.
<OT>
Just a few examples (many of these are Unix-specific):
The user's default shell could be different from the one used by
system(). The program's environment might be different from the
user's environment, perhaps because the program changed it, perhaps
for some other reason. The program might be executed from a cron job,
which has a limited default environment, including a relatively short
$PATH. The command might be an alias or shell function, which would
be invisible to system(). The command might be setuid, i.e.,
impersonating someone else, a possibility you acknowledged above, but
not in your previous followup.
</OT>
I presume there are similar possibilities for other systems.
The point is that the standard makes very few guarantees about how
system() behaves, and assuming, perhaps based on your own experience,
that there are additional guarantees in real life is unwise.