Sunday 27 October 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...