我想编写一个PowerShell脚本,它将在远程PC上执行一个Python脚本。 脚本提示用户input“Y”或“N”继续执行。
要远程login,请键入
enter-pssession -ComputerName <Computer Name> -Credential <DOMAIN>\<username>
然后我input:
python ".\update_software.py"
该脚本在提示符之前打印出文本,但不是提示符,而是收到以下错误消息:
python.exe : Traceback (most recent call last): + CategoryInfo : NotSpecified: (Traceback (most recent call last)::String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError File ".\update_software.py", line 19, in <module> _runner.execute() File "C:\aimplatform2\aim\software_updater\run_update.py", line 76, in execute res = raw_input("> ") EOFError: EOF when reading a line
如果有帮助,我正在运行Windows XP和远程处理到Windows XP机器。
根据python文档,
raw_input([prompt]) -> string Read a string from standard input. The trailing newline is stripped. If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError. On Unix, GNU readline is used if enabled. The prompt string, if given, is printed without a trailing newline before reading.
所以你必须按(或者Powershell可能已经插入了)CTRL + Z在你的raw_input函数中输入。