Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to control a remote Python script, which reads commands from stdin, via psexec 1.98, but I need to redirect psexec's input since psexec itself will be launched from another program. However, I have no luck making psexec accept redirected input. Is it supposed to work at all?

An example of what I'm trying to do, where input is a file containing input to the remote script:

psexec \\mymachine python c:\ < input
share|improve this question
Are you trying to read a file on your computer, or on the remote computer? – cstamas Apr 10 '11 at 21:05
@cstamas: the input file would be local, since psexec's stdin should be redirected to it. – aknuds1 Apr 11 '11 at 17:34
I doubt the answer is yes. PSEXEC has to send the commands you instruct it to run to the remote computer before they are executed (otherwise the command would be incomplete and fail). So that makes me think it does so one time and there's no further interaction with the source computer such that input from later in the command pipeline isn't possible. – Twisty Jan 31 '15 at 22:28
@Twisty You are wrong, since you can run psexec \\someserver -u "user" -p "password" -acceptEula cmd, and provide any further commands you wish. – Asad Saeeduddin Jun 6 at 18:09

The issue is that it thinks that "" is the end of your command. If you put quotes around it

psexec \\mymachine python "c:\ < input"

Then you should be fine.

Additionally, you'll probably need to specify an absolute path to that input file.

Two examples:

psexec \\mymachine python "c:\ < \\input_file_server\input"
psexec \\mymachine python "c:\ < c:\input"

That should do it for you.

share|improve this answer
I don't think this method works? Putting the < operator inside quotes like this makes it part of the argument to Python. I tried it just to check, and in your second example Python thinks it's supposed to open the file "c:\ < c:\input". – aknuds1 Jan 17 '11 at 16:19
Also, are you thinking that I am trying to redirect the input to the Python command? That's not what I am trying to do. I am trying to redirect the input to psexec. – aknuds1 Jan 17 '11 at 16:22

What about these:

psexec \\mymachine cmd /c "python "c:\ < input"


psexec \\mymachine cmd /k "python "c:\ < input"

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.