Qilan2 commited on
Commit
d0abea8
·
verified ·
1 Parent(s): a0c9ade

Update rsync.py

Browse files
Files changed (1) hide show
  1. rsync.py +5 -5
rsync.py CHANGED
@@ -2,21 +2,21 @@ import pexpect
2
  import argparse
3
 
4
  # 设置命令行参数解析
5
- parser = argparse.ArgumentParser(description='Rsync files to a remote server.')
6
  parser.add_argument('--host', required=True, help='Remote host IP address')
7
  parser.add_argument('--port', required=True, help='Remote SSH port')
8
  args = parser.parse_args()
9
 
10
  # 定义变量
11
- local_path = "/sillytavern/"
12
  remote_user = "root"
13
  remote_host = args.host # 从命令行参数获取远程主机
14
  remote_port = args.port # 从命令行参数获取远程端口
15
- remote_path = "/sillytavern/"
16
  password = "qilan" # 将你的密码放在这里
17
 
18
- # 构建 rsync 命令,添加 StrictHostKeyChecking=no
19
- command = f"rsync -avzP -e 'ssh -o StrictHostKeyChecking=no -p {remote_port}' {local_path} {remote_user}@{remote_host}:{remote_path}"
20
 
21
  # 启动子进程并运行命令
22
  child = pexpect.spawn(command)
 
2
  import argparse
3
 
4
  # 设置命令行参数解析
5
+ parser = argparse.ArgumentParser(description='Rsync files from a remote server to local.')
6
  parser.add_argument('--host', required=True, help='Remote host IP address')
7
  parser.add_argument('--port', required=True, help='Remote SSH port')
8
  args = parser.parse_args()
9
 
10
  # 定义变量
11
+ local_path = "/sillytavern/" # 本地路径
12
  remote_user = "root"
13
  remote_host = args.host # 从命令行参数获取远程主机
14
  remote_port = args.port # 从命令行参数获取远程端口
15
+ remote_path = "/sillytavern/" # 远程路径
16
  password = "qilan" # 将你的密码放在这里
17
 
18
+ # 构建 rsync 命令,添加 StrictHostKeyChecking=no,注意源和目标位置的调整
19
+ command = f"rsync -avzP -e 'ssh -o StrictHostKeyChecking=no -p {remote_port}' {remote_user}@{remote_host}:{remote_path} {local_path}"
20
 
21
  # 启动子进程并运行命令
22
  child = pexpect.spawn(command)