Shell 打开 SSH 连接的脚本执行命令
Shell Script to open SSH connection execute a command
我在创建一个脚本时遇到困难,该脚本获取内部包含子文件夹的文件夹,并打开与其他服务器的 ssh 连接,执行 axel 命令从文件夹下载每个文件,然后删除文件夹和文件当工作完成时。
一旦这个服务器和文件夹在互联网上打开,我假装使用 Axel 来加速文件下载。
谁能帮帮我?
谢谢
下面是使用 ssh 连接到远程服务器的脚本
#!/usr/bin/expect -f
spawn ssh $username@$host bash script_to_run_on_server "$directory_path"
sleep 2
expect "password:" {
send "${$password}\r"
}
interact
在上面的脚本中,host,username,password,directory_path是变量,您可以根据自己的值进行替换。
您 'execute an axel command to download each file from the folder, and erase the folder and the files when the job is done'
显示的逻辑写在 script_to_run_on_server
。
注意:确保该目录从服务器环境读取、写入过多。
我在创建一个脚本时遇到困难,该脚本获取内部包含子文件夹的文件夹,并打开与其他服务器的 ssh 连接,执行 axel 命令从文件夹下载每个文件,然后删除文件夹和文件当工作完成时。
一旦这个服务器和文件夹在互联网上打开,我假装使用 Axel 来加速文件下载。
谁能帮帮我?
谢谢
下面是使用 ssh 连接到远程服务器的脚本
#!/usr/bin/expect -f
spawn ssh $username@$host bash script_to_run_on_server "$directory_path"
sleep 2
expect "password:" {
send "${$password}\r"
}
interact
在上面的脚本中,host,username,password,directory_path是变量,您可以根据自己的值进行替换。
您 'execute an axel command to download each file from the folder, and erase the folder and the files when the job is done'
显示的逻辑写在 script_to_run_on_server
。
注意:确保该目录从服务器环境读取、写入过多。