猿问

从 Python 运行 WinSCP 命令

我创建了以下名称为的命令文件submitCmd.txt:


open myname@ftpclients.myserve.com -privatekey=C:\Users\Mike\Desktop\uploader\mykey.ppk

put C:\Users\Mike\Desktop\uploader\files2Upload\myFile.xlsx /mnt/data/myFolder/

close

exit

当我从命令行运行上述脚本时:


winscp.com /script=C:\Users\Mike\Desktop\uploader\submitCmd.txt

它运行成功。


但是,当我在 python 中尝试以下操作时:


cmdFile = r'C:\Users\Mike\Desktop\uploader\submitCmd.txt'

import subprocess

subprocess.run(["winscp.com", "/script=", cmdFile], shell=True)

我收到错误:


Searching for host...

Host "C" does not exist.

winscp> 


紫衣仙女
浏览 413回答 1
1回答
随时随地看视频慕课网APP

相关分类

Python
我要回答