taikoo / parallel-ssh

Automatically exported from code.google.com/p/parallel-ssh
Other
0 stars 0 forks source link

Enhancement: gather files with different names via wildcard #29

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
A problem I had that these tools couldn't solve:

On a set of hosts, I had a number of files, all different by name. I wanted to 
copy them all into one local directory. I ended up doing this:

for f in `cut -f1 -d\  ../hosts`; do scp myuser@${f}:'results-*' .; done

It seems like that's a reasonable use case for these tools to support 
eventually, so I thought I'd mention it.

Thanks!

Original issue reported on code.google.com by wpie...@gmail.com on 12 Nov 2010 at 9:13

GoogleCodeExporter commented 9 years ago
Thanks.  I agree that this would be helpful, but it sounds like it might be a 
bit difficult to come up with a good interface for this.  Do you have any 
suggestions?  
For the ssh side of things, I added an environment variable (PSSH_NODENUM) for 
a similar sort of need, but coming up with a good way to do this with scp might 
be a good deal harder. I'll keep on thinking about it and see if I can come up 
with anything.

Original comment by amcna...@gmail.com on 2 Dec 2010 at 7:25

GoogleCodeExporter commented 9 years ago
Hi,

I sent a patch to massh [1], which is written in bash, maybe it could be ported 
to python ?

The idea is pull to the exact directory where the file is in remote with 
hostname like the first directory in the tree:

--- function in massh:

    files="$(ssh ${List[$Host]} echo "$@")"
    for file in $files
    do
        mkdir -p "$UsrFiles/pull/${List[$Host]}/$(dirname "$file")" &> /dev/null
        scp -pr ${SSHOPTS[*]} ${List[$Host]}:"$file" \
        $UsrFiles/pull/${List[$Host]}"$(dirname "$file")" >/dev/null 
    res=$((res || $?));
    done
    [ $res -eq 0 ] \
        && echo "${List[$Host]} : Pull Succeeded" \
        || echo "${List[$Host]} : Pull Failed"

In my case I would like to do pslurp -h hosts.txt /var/log/*/catalina.out .

Thanks !
[1] http://m.a.tt/er/

Original comment by javibarr...@gmail.com on 13 Sep 2011 at 9:20

GoogleCodeExporter commented 9 years ago
The attached patch implements this behaviour

Original comment by jcp...@gmail.com on 11 Jan 2013 at 6:20

Attachments:

GoogleCodeExporter commented 9 years ago
I was wondering if the attached patch in comment #3 could be considered for a 
merge?

Original comment by jcp...@gmail.com on 1 Oct 2013 at 6:43

GoogleCodeExporter commented 9 years ago
The patch looks straightforward. My only concern is what happens if a user 
happens to have a file with a character like "*" or "?" in the name? Maybe it's 
just a corner case.

Original comment by amcna...@gmail.com on 1 Oct 2013 at 6:51

GoogleCodeExporter commented 9 years ago
Files named like that are going to be a disaster to interact with for most 
command line tools.  The possibility exists, but anyone with those chars in 
their filenames should already know to expect weird behaviour.

Original comment by jcp...@gmail.com on 1 Oct 2013 at 6:54

GoogleCodeExporter commented 9 years ago
Most tools don't actually do globbing themselves, so it's usually not too much 
trouble if you're careful with quoting. I think in this case, the value of 
being able to glob probably outweighs the weird behavior that might be 
introduced, and the comment in the documentation that you included in your 
patch helps to make sure that the behavior is at least clear.

Original comment by amcna...@gmail.com on 1 Oct 2013 at 7:06

GoogleCodeExporter commented 9 years ago

Original comment by amcna...@gmail.com on 1 Oct 2013 at 7:12