Escribí un pequeño script para la tarea en Python. Puede hacer python script.py -p o + r algunos archivos algunos / dir / on / the / server /
import subprocess
import sys
from optparse import OptionParser
DEFAULT_SERVER = 'your.server.com'
parser = OptionParser()
parser.add_option("-p", "--permissions", action="store",
type="str", dest="perm", metavar="PERM",
help="chmod files to PERM", default=None)
parser.add_option("-s", "--server", action="store",
type="str", dest="serv", metavar="SERVER",
help="scp to SERVER", default=DEFAULT_SERVER)
options, args = parser.parse_args()
files = args[:-1]
direct = args[-1]
proc = subprocess.Popen(['scp'] + files + ['%s:%s' % (options.serv, direct)],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if proc.wait() != 0:
print >>sys.stderr, "Uploading failed!"
sys.exit(1)
if options.perm is not None:
arg_dict = dict(dir=direct, perm=options.perm, files=' '.join(files))
proc = subprocess.Popen(['ssh', options.serv, 'cd %(dir)s;'
'chmod -R %(perm)s %(files)s' % arg_dict],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)