2

I am trying to control a remote Python script via psexec, which reads commands from stdin, 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
aknuds1
  • 65,625
  • 67
  • 195
  • 317

1 Answers1

2

Here's one way I was able to kinda accomplish what you're after:

PsExec.exe -d \\\\192.168.1.1 cmd /k "echo list volume | diskpart"

This would pass the commands "list volume" to the diskpart command. Additionally you can also try using cmd like this for you example:

PsExec.exe -d \\\\192.168.1.1 cmd /k "python c:\script.py < input"

slm
  • 15,396
  • 12
  • 109
  • 124
  • I have taken to doing the latter, after copying the response file to the remote machine. I set the command line up like this: `copy input.txt \\machine\X$\WorkingDir && PsExec.exe \\machine -w X:\WorkingDir cmd /k "executable.exe arg1 arg2 arg3 < input.txt & del input.txt"` This copies the file and then cleans it up afterwards. – Thomas S. Trias Sep 07 '11 at 19:58