Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] deleting a local list of filenames from remote server



On Tue, Dec 2, 2008 at 9:22 PM, Charles Muller
<cmuller-lst@example.com> wrote:
> I am thinking that I need to do something that is (logically, at least) like
> this:
>
> ssh user@example.com 'xargs rm < filelist public_html/cache/'
>
> I know that this is not close at all, but I have spent the evening reading
> man pages and Googling around for something equivalent, and so far have not
> been able to come up with something close. I assume that what I want to do
> is possible. Is it?

With ssh, you have basically 2 ways: Using programs/scripts on the remote host,
or running local commands (ie not remote).
Your try cannot work, as you try to run a remote script ("xargs") on a
local file (if I understand
what you tried), which is not accessible from the remote host.

You may then try one of the following:
1) transfer first your file to the server (sftp or equivalent) then
run the command as you did
2) run part of the command locally (list the content of the file
basically), then run the remote
command (rm) on the remote host. Just looks more complicated for me.
Something like "ssh user@example.com rm `cat filelist`"
3) give the input to ssh from localhost. Generate the command locally
(the rm command with filelist),
and pass it as standard input to ssh.
4) run ssh as many times as you have files to delete (basically put
the ssh command inside the
xargs).
5) Having the script running on the remote machine ("rm `ssh
user@example.com cat filelist`").

There are probably tens of ways to do what you want... Just keep in
mind that args to ssh are run
remotely, you will then find the best way for you.

br.

-- 
2 + 2 = 5, for very large values of 2.


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links