There are two differences when using plink ... command
comparing to logging in with PuTTY and typing command
:
plink ... command
opens an "exec" channel to run the command. While PuTTY opens "shell" channel with login shell and only the shell runs the command.
plink ... command
by default opens a non-interactive session (no TTY). While PuTTY opens an interactive session (with TTY).
To test the Plink behavior in PuTTY:
- Enter the command to Connection > SSH > Remote command.
- Check Connection > SSH > TTY > Don't allocate a pseudo-terminal.
Conversely, to test PuTTY behavior in Plink, use:
echo command | plink ...
Check also Plink -T
/-t
switches.
This behaves as PuTTY in 2, but not in 1:
plink -t ... command
Conversely, this behaves as PuTTY in 1, but not in 2:
echo command | plink -T ...
Experiment with these to find out, what is causing your particular problem.
For solutions, see Script via Plink in .bat behaves differently
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…