Jul-29-2021, 12:16 PM
I am currently learning Python in school and have truly enjoyed it. This week we are to working with subprocess. we are to run commands and take screenshots, but the commands they have given us are all for Windows and I run Linux. out of the 15 commands I have figured out all except for one.
The question says:
Use subprocess.Popen to execute the Windows dir command and have its output placed in a text file named pythonOut.txt Hint: The argument for Popen in this case will be subprocess.Popen('C:\\windows\\system32\\cmd.exe "/c dir C:\\ >> C:\\pythonOut.txt"')
I have been racking my brain to find how to do this. I have found that subprocess.Popen(['ls', '-a']) will pull a directory and display it on the screen but how do I output that into a file using a single command line as the Windows example above?
Thank you for your help,
St0rmcr0w
The question says:
Use subprocess.Popen to execute the Windows dir command and have its output placed in a text file named pythonOut.txt Hint: The argument for Popen in this case will be subprocess.Popen('C:\\windows\\system32\\cmd.exe "/c dir C:\\ >> C:\\pythonOut.txt"')
I have been racking my brain to find how to do this. I have found that subprocess.Popen(['ls', '-a']) will pull a directory and display it on the screen but how do I output that into a file using a single command line as the Windows example above?
Thank you for your help,
St0rmcr0w