Sunday, October 27, 2019

bash - Redirecting stdout and stderr output to a file using system command doesn't work in perl





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

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...