When I try to redirect stdout and stderr output of a command onto a file. There is nothing which gets written into a file. This is in a Perl script. I want the stdout and stderr output of a command to be redirected to a file. The code I wrote is this:
system("sudo rm a.txt &>> output.txt");
The file output.txt
doesn't contain anything at all. Can someone help me with this?
Answer
system("sudo rm a.txt >> output.txt 2>&1")
No comments:
Post a Comment