in reply to problem with system(), stdin, and stdout

Usually, if you are reading from STDIN, there's a line feed at the end of each input. If you don't chomp that before putting it into a command line for your "system" call, your sub-shell will get a line break at the end of the string that you've read from stdin, which will be before the angle-bracket redirection, and this means that redirection won't work as intended in the sub-shell.

Chomp your strings from stdin before using them in "system()" calls.

  • Comment on Re: problem with system(), stdin, and stdout