[Bug 291111] Re: pssh (parallel-scp) invalid argument
Brendan Martens
shrift at gmail.com
Fri Feb 20 11:37:07 UTC 2009
Should I be trying to apply this directly to /usr/bin/parallel-scp? When
I do this I get an error:
brendanmartens at hairball:~$ sudo patch /usr/bin/parallel-ssh psh.diff
patching file /usr/bin/parallel-ssh
Hunk #1 FAILED at 21.
1 out of 1 hunk FAILED -- saving rejects to file /usr/bin/parallel-ssh.rej
brendanmartens at hairball:~$
brendanmartens at hairball:~$ cat psh.diff
--- /usr/bin/parallel-scp 2008-05-07 04:54:39.000000000 +0300
+++ parallel-scp 2009-02-20 13:14:44.000000000 +0200
@@ -21,7 +21,10 @@
from psshlib.basethread import BaseThread
_DEFAULT_PARALLELISM = 32
-_DEFAULT_TIMEOUT = sys.maxint # "infinity" by default
+if sys.maxint >> 33:
+ _DEFAULT_TIMEOUT = sys.maxint >> 33
+else:
+ _DEFAULT_TIMEOUT = sys.maxint # "infinity" by default
def print_usage():
print "Usage: pscp [OPTIONS] -h hosts.txt local remote"
brendanmartens at hairball:~$
brendanmartens at hairball:~$ cat /usr/bin/parallel-scp
#!/usr/bin/python
# -*- Mode: python -*-
#
# Usage: pscp [OPTIONS] -h hosts.txt local remote
#
# Parallel scp to the set of nodes in hosts.txt. For each node,
# we essentially do a scp [-r] local user at host:remote. This program
# also uses the -q (quiet) and -C (compression) options. Note
# that remote must be an absolute path.
#
# Created: 16 August 2003
#
# $Id: pscp,v 1.1.1.1 2005/12/31 10:03:33 bnc Exp $
#
import fcntl, os, popen2, pwd, select, signal, sys, threading, time
basedir, bin = os.path.split(os.path.dirname(os.path.abspath(sys.argv[0])))
sys.path.append("%s" % basedir)
import psshlib
from psshlib.basethread import BaseThread
_DEFAULT_PARALLELISM = 32
_DEFAULT_TIMEOUT = sys.maxint # "infinity" by default
def print_usage():
print "Usage: pscp [OPTIONS] -h hosts.txt local remote"
print
print " -r --recursive recusively copy directories (OPTIONAL)"
print " -h --hosts hosts file (each line \"host[:port] [login]\")"
print " -l --user username (OPTIONAL)"
print " -p --par max number of parallel threads (OPTIONAL)"
print " -o --outdir output directory for stdout files (OPTIONAL)"
print " -e --errdir output directory for stderr files (OPTIONAL)"
print " -t --timeout timeout in seconds to do scp to a host (OPTIONAL)"
print " -O --options SSH options (OPTIONAL)"
print
print "Example: pscp -h hosts.txt -l irb2 foo.txt /home/irb2/foo.txt"
print
def read_envvars(flags):
if os.getenv("PSSH_HOSTS"):
flags["hosts"] = os.getenv("PSSH_HOSTS")
if os.getenv("PSSH_USER"):
flags["user"] = os.getenv("PSSH_USER")
if os.getenv("PSSH_PAR"):
flags["par"] = int(os.getenv("PSSH_PAR"))
if os.getenv("PSSH_OUTDIR"):
flags["outdir"] = os.getenv("PSSH_OUTDIR")
if os.getenv("PSSH_ERRDIR"):
flags["errdir"] = os.getenv("PSSH_ERRDIR")
if os.getenv("PSSH_TIMEOUT"):
flags["timeout"] = int(os.getenv("PSSH_TIMEOUT"))
if os.getenv("PSSH_OPTIONS"):
flags["options"] = os.getenv("PSSH_OPTIONS")
def parsecmdline(argv):
import getopt
shortopts = "rh:l:p:o:e:t:O:"
longopts = [ "recursive", "hosts" , "user", "par", "outdir", "errdir",
"timeout", "options" ]
flags = { "recursive" : None, "hosts" : None, "user" : None,
"par" : _DEFAULT_PARALLELISM, "outdir" : None, "errdir" : None,
"timeout" : _DEFAULT_TIMEOUT, "options" : None }
read_envvars(flags)
if not flags["user"]: flags["user"] = pwd.getpwuid(os.getuid())[0] # Default to current user
opts, args = getopt.getopt(argv[1:], shortopts, longopts)
for o, v in opts:
if o in ("-r", "--recursive"):
flags["recursive"] = 1
elif o in ("-h", "--hosts"):
flags["hosts"] = v
elif o in ("-l", "--user"):
flags["user"] = v
elif o in ("-p", "--par"):
flags["par"] = int(v)
elif o in ("-o", "--outdir"):
flags["outdir"] = v
elif o in ("-e", "--errdir"):
flags["errdir"] = v
elif o in ("-t", "--timeout"):
flags["timeout"] = int(v)
elif o in ("-O", "--options"):
flags["options"] = v
# Required flags
if not flags["hosts"]:
print_usage()
sys.exit(3)
return args, flags
def do_pscp(hosts, ports, users, local, remote, flags):
import os
if flags["outdir"] and not os.path.exists(flags["outdir"]):
os.makedirs(flags["outdir"])
if flags["errdir"] and not os.path.exists(flags["errdir"]):
os.makedirs(flags["errdir"])
sem = threading.Semaphore(flags["par"])
threads = []
for i in range(len(hosts)):
sem.acquire()
if flags["options"] and flags["recursive"]:
cmd = "scp -o \"%s\" -qrC -P %d %s %s@%s:%s" % \
(flags["options"], ports[i], local, users[i],
hosts[i], remote)
elif flags["options"] and not flags["recursive"]:
cmd = "scp -o \"%s\" -qC -P %d %s %s@%s:%s" % \
(flags["options"], ports[i], local, users[i],
hosts[i], remote)
elif not flags["options"] and flags["recursive"]:
cmd = "scp -qrC -P %d %s %s@%s:%s" % \
(ports[i], local, users[i], hosts[i], remote)
else:
cmd = "scp -qC -P %d %s %s@%s:%s" % \
(ports[i], local, users[i], hosts[i], remote)
t = BaseThread(hosts[i], ports[i], cmd, flags, sem)
t.start()
threads.append(t)
for t in threads:
t.join()
if __name__ == "__main__":
import os, pwd, re
from psshlib import psshutil
args, flags = parsecmdline(sys.argv)
if len(args) != 2:
print_usage()
sys.exit(3)
local = args[0]
remote = args[1]
if not re.match("^/", remote):
print "Remote path %s must be an absolute path" % remote
sys.exit(3)
hosts, ports, users = psshutil.read_hosts(flags["hosts"])
psshutil.patch_users(hosts, ports, users, flags["user"])
signal.signal(signal.SIGCHLD, psshutil.reaper)
os.setpgid(0, 0)
do_pscp(hosts, ports, users, local, remote, flags)
brendanmartens at hairball:~$
Am I just trying to apply this incorrectly?
--
pssh (parallel-scp) invalid argument
https://bugs.launchpad.net/bugs/291111
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
--
ubuntu-bugs mailing list
ubuntu-bugs at lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
More information about the universe-bugs
mailing list