I'm trying to pull information off a switch using plink. The problem is it keeps trying to insert a "press space to continue" break that I don't seem to be able to turn off. I know that this break is inserted based on the number of rows in the terminal; a manual putty session changes the number of lines scrolled based on window height. How can I change plink's behavior to present enough rows for the queries I'm running to complete without wanting to insert breaks?
The best solution I've found to this is to send the commands to plink out of a text file like this:
plink username@host -pw password < commands.txt
One last issue I encountered is that doing it this way caused it to output a normal session, including the splash message which added a lot of lines to my very carefully-crafted query results. In my situation this was relatively easy to work around as rows with the data I want start with integers and other rows all begin with mixed characters, so I could just build in a simple "if %A equ +%A" check to weed out the useless information.
For those interested, this is what my single-line command looks like:
for /f "tokens=1,2,3,7" %A in ('plink user@host -pw pass ^< commands.txt') do @if %A equ +%A for /f "tokens=2 %E in ('plink user@host -pw pass "command using %C from first command"') do @if not %D == %E @echo %B %C %D %E >> outputfile.txt
It pulls a list and filters it as described above, then uses each row of the list to run a second command to compare a specific bit of information. If a mismatch is found, the relevant information is dropped in the output file.
Now if I could just figure out how to build in variable prompts that I can use inline. Windows 10 processes those differently and they don't work they way they did in previous versions.
(yes this would be easy in a batch file, but ridiculous security policies prevent me running batch files that would make my job much easier. So I build stuff like this monstrosity.)