3

I would like to write a PowerShell script which will execute a Python script on a remote PC. The script prompts the user to type 'Y' or 'N' to continue execution of it.

To log in remotely, I type

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

Then I type:

python ".\update_software.py"

The script prints out the text before the prompt, but instead of the prompt, I receive the following error message:

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

If it helps, I am running Windows XP and remoting into a Windows XP machine.

1 Answer 1

2

According to python documentation,

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.

So you must have pressed (or Powershell might have inserted that) CTRL+Z Enter in your raw_input function.

Sign up to request clarification or add additional context in comments.

3 Comments

So is there any way to execute this script including the prompt or would removing the prompt solve my problems?
try to replace your raw_input and supply the required input as a command line argument to your update_software.py
I did that and the script was able to run. Thanks for your help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.