The problem is that psexeccan only run a program. The following summarizes my test:
FAILURE: psexec dir C:\RmtTools SUCCESS: psexec cmd /c dir C:\RmtTools FAILURE: psexec cmd /c dir C:\RmtTools | sort /r
The full test is hidden behind the readmore tag below.
HOW I SOLVED THIS IN THE PAST: My suggestion is to copy a batch file to the remote system which has your commands in it, and which redirects its final output to a file; then use psexecto execute that batch file; then copy the results file back and parse it.
If you can, it is handy to create a Unique but Known directory on the remote system where such things can be deposited.
There are other ways to work around this limitation -- but psexeccan only run one program -- it does not, in the strictest sense, execute a command line. Pipes are not part of that operating condition.
C:\Steve\Dev\PerlMonks\P-2013-10-24@0940-BackTick-Pipe>psexec \\system +name -u "DOMAIN\User Name" -p password dir C:\RmtTools PsExec v1.94 - Execute processes remotely Copyright (C) 2001-2008 Mark Russinovich Sysinternals - www.sysinternals.com PsExec could not start dir on systemname: The system cannot find the file specified. C:\Steve\Dev\PerlMonks\P-2013-10-24@0940-BackTick-Pipe>psexec \\system +name -u "DOMAIN\User Name" -p password cmd /c dir C:\RmtTools PsExec v1.94 - Execute processes remotely Copyright (C) 2001-2008 Mark Russinovich Sysinternals - www.sysinternals.com Volume in drive C has no label. Volume Serial Number is 1402-8CDA Directory of C:\RmtTools 10/24/2013 10:09 AM <DIR> . 10/24/2013 10:09 AM <DIR> .. 10/24/2013 09:50 AM 22 test.dat 10/24/2013 09:50 AM 22 test1.dat 10/24/2013 09:50 AM 22 test2.dat 10/24/2013 09:50 AM 22 test3.dat 4 File(s) 88 bytes 2 Dir(s) 17,756,794,880 bytes free cmd exited on systemname with error code 0. C:\Steve\Dev\PerlMonks\P-2013-10-24@0940-BackTick-Pipe>psexec \\system +name -u "DOMAIN\User Name" -p password cmd /c dir C:\RmtTools | sort +/r PsExec v1.94 - Execute processes remotely Copyright (C) 2001-2008 Mark Rusorts: sopen failed: /ri: nNo such file + or directoryo ich Sysinternals - www.sysinternals.com cmd exited on systemname with error code 0.
In reply to Re: netstat on remote with perl (possible?)
by marinersk
in thread netstat on remote with perl (possible?)
by softestplease
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |