あなたはあなたのためにそれを行うためのPythonスクリプトが必要になります。 私はpython paramiko、scpを使って、それらの使い方については、きれいな文書 を探します。
pip install scp
easy_install paramiko
私のPC(Ubuntu 16.04)64bitでのテスト。少し変更を加える必要があります。サーバー名、ユーザー名、パスワード、ファイルをアップロードするリモートディレクトリです。
import os
import sys
import glob
import fnmatch
import paramiko # for ssh may need to be installed.
from scp import SCPClient
import time
# This may work on both linux and window or mac.
DEFAULT_DIR=os.path.expanduser("~")
server="192.168.0.100"
port=22
user="s8software"
password="!your-password.com!" # may not bee needed when we use public key something.pem
SFTP_REMOTE_PATH="/home/s8software/Documents/"
def search_directory_for_files(dirname, extension="*.py"):
"""
Search an entire directory for particular files
denoted with extension. and copy them to a remote server.
@param: dirname--> The directory contains files we want to copy.
@param: extension--> The files with a particular extension we want to copy.
"""
if (not dirname):
raise AttributeError("We need at least a source directory!")
for root, direname, filenames in os.walk(dirname):
for filename in fnmatch.filter(filenames, extension):
yield {"fullpath":os.path.join(root, filename), "filename":filename}
def open_scp_connection(server, port, user, password):
"""
Function returns a well established connection to the
server we want to transfer files to.
"""
try:
client = paramiko.SSHClient()
client.load_system_host_keys()
# Note the public key here don't.
# TODO. See how you can either pass the username and password.
pkey = "/home/s8software/Working/Keys/KeParis/TestInstance.pem"
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# NOTE: if you use the public_key then uncomment this line and comment
# the one using the password.
#client.connect(server, port, user, key_filename=pkey)
client.connect(server, port, user, password=password)
return client
except:
raise
def get_scpclient_connection(ssh_object):
try:
return SCPClient(ssh_object.get_transport())
except:
raise
def _send_remote_recursive(scp_client, file_full_path, filename):
"""
Given a file send them to the remote server.
"""
try:
print time.asctime(), 'Uploading....', filename
return_status = scp_client.put(file_full_path, remote_path=os.path.join(SFTP_REMOTE_PATH, filename))
except:
raise
else:
return return_status
if __name__=="__main__":
# First open the connection using the port of the server
endpoint_connection = open_scp_connection(server, port, user, password)
scp_connection = get_scpclient_connection(endpoint_connection)
# Recursely get everything we need and send to remove server.
for f in search_directory_for_files(DEFAULT_DIR):
source_path = f.get("fullpath")
filename = f.get("filename")
# Send the files to the remote server.
_send_remote_recursive(scp_connection, source_path, filename)
私は必要ありますが少し修正しました。
[root @ DVRTPG009回帰]#cat annc1.xml | grep 3gp 01 –
user2465903