plink.exe - setting number of rows in terminal?
up vote
-1
down vote
favorite
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?
command-line putty plink
add a comment |
up vote
-1
down vote
favorite
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?
command-line putty plink
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
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?
command-line putty plink
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?
command-line putty plink
command-line putty plink
asked Nov 9 at 14:53
FTBC
113
113
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
To automate commands, you should run your SSH client without terminal emulation in the first place. This way, you won't have to deal with problems like this.
Plink (similarly to OpenSSH ssh
client) does not use the terminal emulation, when you specify the command on Plink's command-line:
plink username@host less file.txt
This way, the less
command (and similar) would behave like simple cat
, as there's no terminal.
Some obscure SSH servers, like those running on some switches, do not support the SSH "exec" channel used by Plink for execute the command specified on its command-line.
If that's your case, you are probably passing the command to Plink using input redirection like:
echo less file.txt | plink username@host
In this case, Plink uses terminal emulation. So less
will paginate the output.
To stop Plink from using terminal emulation, use -T
switch:
echo less file.txt | plink username@host -T
I've tried the -T switch and got the same result. Here's the command I just ran:plink username@host -pw password -T "command"
And it pauses after ~20 lines. (edit: just started using stackoverflow, the text field is...less than intuitive. So excuse my lack of line breaks)
– FTBC
Nov 9 at 15:33
If you run your command in PuTTY in a maximized window, when does the command pause?
– Martin Prikryl
Nov 9 at 15:41
Roughly after the screen fills. I think it's actually an additional two lines. Which is why I was looking for a way to tell it plink has 9000 rows since it doesn't seem to care if it use the -T switch.
– FTBC
Nov 9 at 15:51
If you use-T
switch, Plink won't even tell the remote side that it has any number of lines. Decent command will then do not paginate. Maybe your SSH server or command falls back to some hard-coded number of lines instead [what is a bug imo]. In such case, you can try to create a stored session in PuTTY with a default window size set to 9000 rows (if even possible) and use that stored session in Plink (with-t
switch [not-T
] to force terminal emulation) - likeplink session -t command
. Though I'm not even sure, if windows size setting has any effect on Plink.
– Martin Prikryl
Nov 9 at 15:57
If not, you are out of luck imo. - You would have to use another command-line/scriptable SSH client that can behave like it has a window of set size.
– Martin Prikryl
Nov 9 at 15:58
|
show 4 more comments
up vote
0
down vote
accepted
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.)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53228064%2fplink-exe-setting-number-of-rows-in-terminal%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
To automate commands, you should run your SSH client without terminal emulation in the first place. This way, you won't have to deal with problems like this.
Plink (similarly to OpenSSH ssh
client) does not use the terminal emulation, when you specify the command on Plink's command-line:
plink username@host less file.txt
This way, the less
command (and similar) would behave like simple cat
, as there's no terminal.
Some obscure SSH servers, like those running on some switches, do not support the SSH "exec" channel used by Plink for execute the command specified on its command-line.
If that's your case, you are probably passing the command to Plink using input redirection like:
echo less file.txt | plink username@host
In this case, Plink uses terminal emulation. So less
will paginate the output.
To stop Plink from using terminal emulation, use -T
switch:
echo less file.txt | plink username@host -T
I've tried the -T switch and got the same result. Here's the command I just ran:plink username@host -pw password -T "command"
And it pauses after ~20 lines. (edit: just started using stackoverflow, the text field is...less than intuitive. So excuse my lack of line breaks)
– FTBC
Nov 9 at 15:33
If you run your command in PuTTY in a maximized window, when does the command pause?
– Martin Prikryl
Nov 9 at 15:41
Roughly after the screen fills. I think it's actually an additional two lines. Which is why I was looking for a way to tell it plink has 9000 rows since it doesn't seem to care if it use the -T switch.
– FTBC
Nov 9 at 15:51
If you use-T
switch, Plink won't even tell the remote side that it has any number of lines. Decent command will then do not paginate. Maybe your SSH server or command falls back to some hard-coded number of lines instead [what is a bug imo]. In such case, you can try to create a stored session in PuTTY with a default window size set to 9000 rows (if even possible) and use that stored session in Plink (with-t
switch [not-T
] to force terminal emulation) - likeplink session -t command
. Though I'm not even sure, if windows size setting has any effect on Plink.
– Martin Prikryl
Nov 9 at 15:57
If not, you are out of luck imo. - You would have to use another command-line/scriptable SSH client that can behave like it has a window of set size.
– Martin Prikryl
Nov 9 at 15:58
|
show 4 more comments
up vote
0
down vote
To automate commands, you should run your SSH client without terminal emulation in the first place. This way, you won't have to deal with problems like this.
Plink (similarly to OpenSSH ssh
client) does not use the terminal emulation, when you specify the command on Plink's command-line:
plink username@host less file.txt
This way, the less
command (and similar) would behave like simple cat
, as there's no terminal.
Some obscure SSH servers, like those running on some switches, do not support the SSH "exec" channel used by Plink for execute the command specified on its command-line.
If that's your case, you are probably passing the command to Plink using input redirection like:
echo less file.txt | plink username@host
In this case, Plink uses terminal emulation. So less
will paginate the output.
To stop Plink from using terminal emulation, use -T
switch:
echo less file.txt | plink username@host -T
I've tried the -T switch and got the same result. Here's the command I just ran:plink username@host -pw password -T "command"
And it pauses after ~20 lines. (edit: just started using stackoverflow, the text field is...less than intuitive. So excuse my lack of line breaks)
– FTBC
Nov 9 at 15:33
If you run your command in PuTTY in a maximized window, when does the command pause?
– Martin Prikryl
Nov 9 at 15:41
Roughly after the screen fills. I think it's actually an additional two lines. Which is why I was looking for a way to tell it plink has 9000 rows since it doesn't seem to care if it use the -T switch.
– FTBC
Nov 9 at 15:51
If you use-T
switch, Plink won't even tell the remote side that it has any number of lines. Decent command will then do not paginate. Maybe your SSH server or command falls back to some hard-coded number of lines instead [what is a bug imo]. In such case, you can try to create a stored session in PuTTY with a default window size set to 9000 rows (if even possible) and use that stored session in Plink (with-t
switch [not-T
] to force terminal emulation) - likeplink session -t command
. Though I'm not even sure, if windows size setting has any effect on Plink.
– Martin Prikryl
Nov 9 at 15:57
If not, you are out of luck imo. - You would have to use another command-line/scriptable SSH client that can behave like it has a window of set size.
– Martin Prikryl
Nov 9 at 15:58
|
show 4 more comments
up vote
0
down vote
up vote
0
down vote
To automate commands, you should run your SSH client without terminal emulation in the first place. This way, you won't have to deal with problems like this.
Plink (similarly to OpenSSH ssh
client) does not use the terminal emulation, when you specify the command on Plink's command-line:
plink username@host less file.txt
This way, the less
command (and similar) would behave like simple cat
, as there's no terminal.
Some obscure SSH servers, like those running on some switches, do not support the SSH "exec" channel used by Plink for execute the command specified on its command-line.
If that's your case, you are probably passing the command to Plink using input redirection like:
echo less file.txt | plink username@host
In this case, Plink uses terminal emulation. So less
will paginate the output.
To stop Plink from using terminal emulation, use -T
switch:
echo less file.txt | plink username@host -T
To automate commands, you should run your SSH client without terminal emulation in the first place. This way, you won't have to deal with problems like this.
Plink (similarly to OpenSSH ssh
client) does not use the terminal emulation, when you specify the command on Plink's command-line:
plink username@host less file.txt
This way, the less
command (and similar) would behave like simple cat
, as there's no terminal.
Some obscure SSH servers, like those running on some switches, do not support the SSH "exec" channel used by Plink for execute the command specified on its command-line.
If that's your case, you are probably passing the command to Plink using input redirection like:
echo less file.txt | plink username@host
In this case, Plink uses terminal emulation. So less
will paginate the output.
To stop Plink from using terminal emulation, use -T
switch:
echo less file.txt | plink username@host -T
edited Nov 9 at 15:30
answered Nov 9 at 15:20
Martin Prikryl
84.7k22163353
84.7k22163353
I've tried the -T switch and got the same result. Here's the command I just ran:plink username@host -pw password -T "command"
And it pauses after ~20 lines. (edit: just started using stackoverflow, the text field is...less than intuitive. So excuse my lack of line breaks)
– FTBC
Nov 9 at 15:33
If you run your command in PuTTY in a maximized window, when does the command pause?
– Martin Prikryl
Nov 9 at 15:41
Roughly after the screen fills. I think it's actually an additional two lines. Which is why I was looking for a way to tell it plink has 9000 rows since it doesn't seem to care if it use the -T switch.
– FTBC
Nov 9 at 15:51
If you use-T
switch, Plink won't even tell the remote side that it has any number of lines. Decent command will then do not paginate. Maybe your SSH server or command falls back to some hard-coded number of lines instead [what is a bug imo]. In such case, you can try to create a stored session in PuTTY with a default window size set to 9000 rows (if even possible) and use that stored session in Plink (with-t
switch [not-T
] to force terminal emulation) - likeplink session -t command
. Though I'm not even sure, if windows size setting has any effect on Plink.
– Martin Prikryl
Nov 9 at 15:57
If not, you are out of luck imo. - You would have to use another command-line/scriptable SSH client that can behave like it has a window of set size.
– Martin Prikryl
Nov 9 at 15:58
|
show 4 more comments
I've tried the -T switch and got the same result. Here's the command I just ran:plink username@host -pw password -T "command"
And it pauses after ~20 lines. (edit: just started using stackoverflow, the text field is...less than intuitive. So excuse my lack of line breaks)
– FTBC
Nov 9 at 15:33
If you run your command in PuTTY in a maximized window, when does the command pause?
– Martin Prikryl
Nov 9 at 15:41
Roughly after the screen fills. I think it's actually an additional two lines. Which is why I was looking for a way to tell it plink has 9000 rows since it doesn't seem to care if it use the -T switch.
– FTBC
Nov 9 at 15:51
If you use-T
switch, Plink won't even tell the remote side that it has any number of lines. Decent command will then do not paginate. Maybe your SSH server or command falls back to some hard-coded number of lines instead [what is a bug imo]. In such case, you can try to create a stored session in PuTTY with a default window size set to 9000 rows (if even possible) and use that stored session in Plink (with-t
switch [not-T
] to force terminal emulation) - likeplink session -t command
. Though I'm not even sure, if windows size setting has any effect on Plink.
– Martin Prikryl
Nov 9 at 15:57
If not, you are out of luck imo. - You would have to use another command-line/scriptable SSH client that can behave like it has a window of set size.
– Martin Prikryl
Nov 9 at 15:58
I've tried the -T switch and got the same result. Here's the command I just ran:
plink username@host -pw password -T "command"
And it pauses after ~20 lines. (edit: just started using stackoverflow, the text field is...less than intuitive. So excuse my lack of line breaks)– FTBC
Nov 9 at 15:33
I've tried the -T switch and got the same result. Here's the command I just ran:
plink username@host -pw password -T "command"
And it pauses after ~20 lines. (edit: just started using stackoverflow, the text field is...less than intuitive. So excuse my lack of line breaks)– FTBC
Nov 9 at 15:33
If you run your command in PuTTY in a maximized window, when does the command pause?
– Martin Prikryl
Nov 9 at 15:41
If you run your command in PuTTY in a maximized window, when does the command pause?
– Martin Prikryl
Nov 9 at 15:41
Roughly after the screen fills. I think it's actually an additional two lines. Which is why I was looking for a way to tell it plink has 9000 rows since it doesn't seem to care if it use the -T switch.
– FTBC
Nov 9 at 15:51
Roughly after the screen fills. I think it's actually an additional two lines. Which is why I was looking for a way to tell it plink has 9000 rows since it doesn't seem to care if it use the -T switch.
– FTBC
Nov 9 at 15:51
If you use
-T
switch, Plink won't even tell the remote side that it has any number of lines. Decent command will then do not paginate. Maybe your SSH server or command falls back to some hard-coded number of lines instead [what is a bug imo]. In such case, you can try to create a stored session in PuTTY with a default window size set to 9000 rows (if even possible) and use that stored session in Plink (with -t
switch [not -T
] to force terminal emulation) - like plink session -t command
. Though I'm not even sure, if windows size setting has any effect on Plink.– Martin Prikryl
Nov 9 at 15:57
If you use
-T
switch, Plink won't even tell the remote side that it has any number of lines. Decent command will then do not paginate. Maybe your SSH server or command falls back to some hard-coded number of lines instead [what is a bug imo]. In such case, you can try to create a stored session in PuTTY with a default window size set to 9000 rows (if even possible) and use that stored session in Plink (with -t
switch [not -T
] to force terminal emulation) - like plink session -t command
. Though I'm not even sure, if windows size setting has any effect on Plink.– Martin Prikryl
Nov 9 at 15:57
If not, you are out of luck imo. - You would have to use another command-line/scriptable SSH client that can behave like it has a window of set size.
– Martin Prikryl
Nov 9 at 15:58
If not, you are out of luck imo. - You would have to use another command-line/scriptable SSH client that can behave like it has a window of set size.
– Martin Prikryl
Nov 9 at 15:58
|
show 4 more comments
up vote
0
down vote
accepted
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.)
add a comment |
up vote
0
down vote
accepted
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.)
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
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.)
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.)
answered Nov 15 at 17:03
FTBC
113
113
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53228064%2fplink-exe-setting-number-of-rows-in-terminal%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown