Qilan2 commited on
Commit
3916779
·
verified ·
1 Parent(s): fc9f187

Update rsync.py

Browse files
Files changed (1) hide show
  1. rsync.py +10 -3
rsync.py CHANGED
@@ -1,12 +1,19 @@
1
  import pexpect
 
 
 
 
 
 
 
2
 
3
  # 定义变量
4
  local_path = "/sillytavern/"
5
  remote_user = "root"
6
- remote_host = "8.217.96.17"
7
- remote_port = "7072"
8
  remote_path = "/sillytavern/"
9
- password = "qilan"
10
 
11
  # 构建 rsync 命令,添加 StrictHostKeyChecking=no
12
  command = f"rsync -avzP -e 'ssh -o StrictHostKeyChecking=no -p {remote_port}' {local_path} {remote_user}@{remote_host}:{remote_path}"
 
1
  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}"