Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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:\script.py < 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

2 Answers 2

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

psexec \\mymachine python "c:\script.py < 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:\script.py < \\input_file_server\input"
OR
psexec \\mymachine python "c:\script.py < 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:\script.py < 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:\script.py < input"

-or-

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

share|improve this answer

Your Answer

 
discard

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.