Reputation: 259
My question is regarding the way the file ("-m" switch) is used by Plink.
My command is:
plink.exe -ssh [email protected] -pw p@ss30rd -m commandfile.txt
I'm trying to connect to a switch and execute these 3 commands:
system-view
user-interface vty 0
screen-length 200
The issue here, is that each command depends on it's predecessor. In other word, executing the command system-view
gives access to a new level or a context where the second command user-interface vty 0
can be valid and executed and same thing for the third command in which is only valid (and available) only if user-interface vty 0
is executed
Is there a way or a workaround that we can achieve this using Plink?
My goal here is to put the "Plink" command line in a script and try to analyse the output
Thanks in advance
Upvotes: 1
Views: 2416
Reputation: 202262
If you specify multiple commands using the -m
switch, they are executed one after another. While you (if I understand you correctly) want to execute the commands within each other. That's not possible with the -m
switch.
What you can do, is to feed the commands to Plink using an input redirection. This way, Plink behaves, just as, if you typed those commands.
(
echo system-view
echo user-interface vty 0
echo screen-length 200
) | plink.exe -ssh [email protected] -pw p@ss30rd
Note that by default, with the -m
switch, Plink does not allocate a pseudo terminal, while with the input redirection, it does. So the behavior is not identical. You can use the -t
/-T
switches to override that.
Upvotes: 1