Problem with plink output

1.6k views Asked by At

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 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?

2

There are 2 answers

0
Ryan Gareau On
  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
pedrocgsousa On

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.