3

リモートPCでPythonスクリプトを実行するPowerShellスクリプトを作成したいと思います。スクリプトは、実行を続行するために「Y」または「N」を入力するようにユーザーに促します。

リモートでログインするには、次のように入力します

enter-pssession -ComputerName <Computer Name> -Credential <DOMAIN>\<username>

次に、次のように入力します。

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を実行していて、WindowsXPマシンにリモート接続しています。

4

1 に答える 1

2

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 関数に入力します。

于 2012-07-28T21:44:45.890 に答える