开发者

Problem with plink output

开发者 https://www.devze.com 2023-02-07 23:02 出处:网络
I\'m using plink to run a command on a Unix remote machine. The command is: ls -1trd testegrep.txt |tail -1 |xargs tail -f| grep \'s\';

I'm using plink to run a command on a Unix remote machine. The command is:

ls -1trd testegrep.txt |tail -1 |xargs tail -f| grep 's';

The way I'm sending this command is by using a file with a set of commands like:

plink.exe -ssh -t -l user -pw pwd tst.url.pt -m commands.out

When I run the command this way the plink does not receive any input. It seems that is waiting开发者_Go百科 for input. But if I run:

plink.exe -ssh -t -l user -pw pwd tst.url.pt "ls -1trd testegrep.txt |tail -1 |xargs tail -f| grep 's';"

I get the expected result.

I'm not using the plink with a file with the command because I choose so. I'm using a test automation software that allows me to run tests on remote hosts and this is the way the tool works.

Any thoughts on what is going wrong?


I tested the command you provided and it worked without problems.

Maybe the problem is related to:

  1. The server's host key is not cached in the registry.
  2. The path to the file is not correct.
  3. The file is empty.


  1. include server hostkey
  2. most importantly, you need to include the unix profile using the -m paramater

You can include all your commands in the same file where the profile is kept also.

$Output = ((plink.exe -hostkey hostkey -l UNAME -i SSHKEY -P 22 -ssh server -batch -m PROFILE) | ? {$_ -ne ""})
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号