You are here

Copy/pasting large amounts of text via a PuTTY terminal

Submitted by Druss on Sat, 2014-08-02 23:23

While transferring a file to a remote server is pretty easily done using PuTTY's sister program, pscp, sometimes one finds oneself to be too lazy to go through the steps required. Shouldn't it be possible to simply copy and paste the (text) file into a remote editor via PuTTY? It is and it works a peach. However, it does crack the shits every now and then complaining about the length of the clipboard (paste).

Today, I wanted to transfer a large block of text (i.e., a file) full of delimited data and found PuTTY complaining about the process. I ran into flashing screens (flashing away for a few minutes) and incomplete sentences. I thought that this was perhaps happening due to the size of the transfer and sure enough, when I broke up the copy/paste procedure into about 10 separate chunks, things worked great. But this was not terribly ideal. I could have simply pscp'd the file instead of taking this long way around.

I then tried another tack. Instead of assuming that the problem was with the size of the transfer, I reasoned that if the screen was flashing repeatedly, it must have been doing so for each line that was being pasted. Therefore, PuTTY/terminal must have been transferring the paste line by line and furthermore, it was the length of the line that was the problem. So, what I did was break up the file (using regular expressions) into smaller sized lines along with a marker (a string like ##) to denote my alterations. I then proceed to copy/paste the contents of the now streamlined file into PuTTY, and VOILA!, it worked like a charm.

(FWIW, my delimited text file was actually storing CRLFs as \n combinations. All I needed to do was to replace the \n to a real line-break which was all that was needed in my case.)

Hope this helps!