in reply to help on system function

Without additional information, my suspicion would be that system() is invoking /bin/sh to execute your command, and that /bin/sh does not provide a 'history' built-in.

Another alternative may be that system() is invoking your shell in non-interactive mode, and the commands that you are trying to use only exist in interactive mode, or only provide the expected output in interactive mode.