shell - 如何在远程服务器上通过 ssh 执行多个命令
问题描述
我想通过 shell 脚本从 AWS 存储桶中获取日志,下面是我的示例脚本,它在获取日志文件的路径上一一对应。
echo "Enter user_name"
read name
echo "Enter the bucket for which you want to see the logs"
echo "applicationLogs / nginxLogs"
echo
read bucket_logs
echo "Enter the Date (yyyy-mm-dd:)"
read date
echo "Enter the bucket server ip"
read bucket_ip
echo $bucket_ip > iplist
newip=$(sed 's/\./-/g' iplist)
aws_server_ip="1*.4*.2*.2**"
IP="ip"
bucket_region="ap-south-1.compute.internal"
aws_bucket="aws s3 ls s3://wallet-prod-backup-bucket/"
ssh $name@$aws_server_ip ${aws_bucket}{${bucket_logs}/${bucket_ip}/${IP}-${newip}.${bucket_region}/${date}/alog/wallet-service/walletlogs/wallet-service/
我需要运行多个命令(即首先我通过 ssh 连接到服务器,然后我需要通过不同的路径复制日志文件夹)。当我从我的机器本地运行此脚本时,它会转到所需的路径,列出日志文件,但立即从服务器退出。有什么方法可以让我在不退出远程服务器的情况下通过 ssh 运行命令?
解决方案
推荐阅读
- python - 比较 Pandas 列中的 2 个重复值
- material-ui - DataGrid 不显示在带有 filterValues 的选项卡内
- python - 良好的准确性,较少的损失,错误的类别预测 Tf/keras
- php - 在关联数组 PHP 中查找重复项,比较它们的值
- asp.net-mvc-5 - 如何在 mvc 5 编辑中保留当前图像
- php - 如何将准备好的语句输入放入数据库
- html - 防止在 mailto 上导航:链接
- angular - 如何在角度 5 中获取基本 url 和路径?
- php - 雄辩的 Laravel 关系 - 用户要么是学生,要么是老师,一对一的关系
- javascript - 为什么将 Ember 从 1.13 升级到 2.3 会中断 fastboot?