2012-07-28 92 views
2

我想编写一个PowerShell脚本,它将在远程PC上执行Python脚本。脚本提示用户输入'Y'或'N'继续执行。Windows PowerShell - 与Python脚本进行交互远程PC

远程登录,I型

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

然后I型:

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机器。

回答

1

根据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输入。

+0

那么有没有什么办法来执行这个脚本,包括提示或将删除提示解决我的问题? – Parth 2012-07-28 22:23:02

+0

尝试替换raw_input并将所需的输入作为命令行参数提供给update_software.py – Meitham 2012-07-28 22:26:52

+0

我这样做了,脚本能够运行。谢谢你的帮助 – Parth 2012-07-30 21:08:01