Thanks for the answer. Your solution doesn't work. Output of the program run by system call still is being printed to the screen and not to the log file. Perhaps you should have spend less time on being a pedantic prick and spend 5 seconds on actually running the code you provided.