Putty won't accept command longer than a few lines
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Putty won't accept command longer than a few lines
Hello,
I'm trying to delete a large number of files from my web site using the "rm -f" command in Putty:
i.e. rm -f myFile.txt myFile1.txt myFile2.txt, myFile3.txt, myFile4.txt, etc.
For some reason, when I paste more than 4 or 5 lines into Putty, the text gets truncated. I have several thousand files to remove so I really need this to work. Even if I could delete 50 files at a time I would be happy.
I'm doing everything properly like pressing Shift+Insert to paste the text into the command window, but the software itself just doesn't seem to accept more than a few lines at once. I tried shortening my list multiple times with the same result.
Any help is greatly appreciated. I really need this to work asap.
First off, are you sure that it is Putty that is the problem? Open a text document and paste what is in you clipboard into the document. See if it matches what you expected.
I'm pretty sure that it will, but you should check in any case.
So far, all that I can come up with is extending the size of your window (which ties in to an old bug where text outside of that window was getting truncated). But I figure that you would have already tried this.
As described in section 3.1.1, PuTTY has two modes of selecting text to be copied to the clipboard. In the default mode (‘Normal’), dragging the mouse from point A to point B selects to the end of the line containing A, all the lines in between, and from the very beginning of the line containing B. In the other mode (‘Rectangular block’), dragging the mouse between two points defines a rectangle, and everything within that rectangle is copied.
Normally, you have to hold down Alt while dragging the mouse to select a rectangular block. Using the ‘Default selection mode’ control, you can set rectangular selection as the default, and then you have to hold down Alt to get the normal behaviour.
"
If you are deleting all the files it may be easier to delete the entire directory (assuming no subdirectories) with "rm -r <name>" and recreate the directory.
Another way to delete a lot of files, but not all, is to select some characteristic of the file name that groups it - something like "rm a*" will delete all files starting with "a" (up to about 10,000 files that is -it varies depending on how long the file names are- after that you can get a parameter list overflow error).
Right. I agree with jpollard. You want to place those files somewhere and delete the entire directory. For instance if there are files in the directory which you want to keep, then choose the lesser action and move one set away from the other. Or use wildcards which identify the specific subset of files you wish to delete; however I'm more a fan of placing the "to be deleted" files in a certain place for deletion.
I think I finally figured out why this is happening. So I tried it again, also using the methods that were suggested here, but still without any luck unfortunately.
I then tried it on a different web site/server using a "root" log-in. And surprise: I can paste as many lines as I want as long as I'm logged-in as "root".
However, on this particular server, I don't have a root log-in account. I only have a personal user account. Even though I can perform a big deletion task on my one server, I still can't do it on the server that actually needs this task done on it.
So I guess logging-in as "root" is a prerequisite for this? Are there any other ways around it?
if you know all the file names you want to delete, paste them into a script to delete them and upload it to your sever and run it; of course, it needs to be said that you should be very careful with this.
if you know all the file names you want to delete, paste them into a script to delete them and upload it to your sever and run it; of course, it needs to be said that you should be very careful with this.
Can you provide more information about this?
Alternatively: Is there a reliable desktop macro that I can I use to simply copy each file into SSH and delete it?
I have a list of all the files that I want to delete in a text file, with "rm -f /path/file.php" on each line.
I would want the macro to copy each line over to PuTTY and simple click the enter key which would delete it.
I use iMacros for the Web, but is there something simple like this that works on the desktop?
There are several ways to do it, even without scripting.
Ant to be honest, I'd try to figure out some pattern instead of typing 1000+ file names into the CLI.
In case you had a Windows machine in place running WinSCP you could just select the files you want to delete and let WinSCP do the job for you.
Do you have any file manager installed on the system, e.g. good old midnight commander? Use that one.
Webmin could be used for this as well.
it would probably make sense to install mc for tasks like this, but Webmin i'd only use if it was there anyway.
I definitely do not want to copy and paste all the URLs, but that's why I was thinking a macro might be good for the task. I've used iMacros before, but am not familiar with any desktop macros.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.