I am working on a unix script that needs some adaptations to work under windows 10. The script uses subprocess to perform file operations using DOS commands. Specifically, a statement that uses subprocess to copy a file from a directory to the current directory returns an error message. The correct DOS command is
copy "D:\tess\catalog files\TIC55234031.fts" .
However,
ref_fits_filename="D:\TESS\catalog files\TIC55234031.fts"
and
subprocess.call(['copy ', ref_fits_filename,' .']) # copy the ref fits file to here
which aims to perform exactly the same operation, goes wrong:
Traceback (most recent call last): File "EBcheck.py", line 390, in subprocess.call(['copy ', ref_fits_filename,' .']) # copy the ref fits file to here File "C:\Users\FD-Computers\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 267, in call with Popen(*popenargs, **kwargs) as p: File "C:\Users\FD-Computers\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 709, in __init__ restore_signals, start_new_session) File "C:\Users\FD-Computers\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 997, in _execute_child startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified
Obviously, there must be a subtle syntax error or an issue I haven't though of that causes the problem. Are there experts in Python programmming under windows 10 to clarify the issue on this forum ? The Python version used here is the recent Python 3.6.4.