मैंने पायथन में कार्य के लिए एक छोटी स्क्रिप्ट लिखी। आप python script.py -p o + r कुछ फाइल्स को कुछ / dir / on / / 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)