I have a script which, when I run it from PuTTY, it scrolls the screen. Now, I want to go back to see the errors, but when I scroll up, I can see the past commands, but not the output of the command.
How can I see the past output?
Shift+Pgup/PgDn should work for scrolling without using the scrollbar.
If you don't pipe the output of your commands into something like
less, you will be able to use Putty's scroll-bars to view earlier output.
Putty has settings for how many lines of past output it retains in it's buffer.
after scrolling back (upwards)
If you use something like
less the output doesn't get into Putty's scroll buffer
after using less
I would recommend using screen if you want to have good control over the scroll buffer on a remote shell.
You can change the scroll buffer size to suit your needs by setting:
~/.screenrc, which will specify the number of lines you want to be buffered (4000 in this case).
Then you should run your script in a screen session, e.g. by executing
screen ./myscript.sh or first executing
screen and then
./myscript.sh inside the session.
It's also possible to enable logging of the console output to a file. You can find more info on the screen's man page.
From your descript, it sounds like the "problem" is that you are using screen, tmux, or another window manager dependent on them (byobu). Normally you should be able to scroll back in putty with no issue. Exceptions include if you are in an application like less or nano that creates it's own "window" on the terminal.
With screen and tmux you can generally scroll back with
SHIFT + PGUP (same as you could from the physical terminal of the remote machine). They also both have a "copy" mode that frees the cursor from the prompt and lets you use arrow keys to move it around (for selecting text to copy with just the keyboard). It also lets you scroll up and down with the
PGDN keys. Copy mode under byobu using screen or tmux backends is accessed by pressing
F6 disconnects the session). To do so directly under screen you press
CTRL + a then
[. You can use
ESC to exit copy mode. Under tmux you press
CTRL + b then
[ to enter copy mode and
] to exit.
The simplest solution, of course, is not to use either. I've found both to be quite a bit more trouble than they are worth. If you would like to use multiple different terminals on a remote machine simply connect with multiple instances of putty and manage your windows using, er... Windows. Now forgive me but I must flee before I am burned at the stake for my heresy.
EDIT: almost forgot, some keys may not be received correctly by the remote terminal if putty has not been configured correctly. In your putty config check
Terminal -> Keyboard. You probably want the function keys and keypad set to be either
Xterm R6. If you are seeing strange characters on the terminal when attempting the above this is most likely the problem.