如何写一个能登录远程服务器并执行命令的shell脚本
摘要:以下是一个示例 shell 脚本,它可以登录远程服务器并执行命令 #!/bin/bash # 设置远程服务器的 IP 地址和用户名 echo "Enter remote server IP: " read remote_ip echo "Enter remote server username: "
阅读全文
posted @
2023-05-10 23:53
jarsing
阅读(1845)
推荐(0) 编辑
shelll脚本创建一个文件,并写入内容
摘要:下面是一个简单的 shell 脚本,它可以创建一个名为"hello.txt"的文件,并向其中写入"hello world" #!/bin/bash # 创建文件 touch hello.txt # 向文件写入内容 cat hello.txt | tr -d '\n' > /dev/null echo
阅读全文
posted @
2023-05-10 23:38
jarsing
阅读(3741)
推荐(0) 编辑
expect脚本实现ssh自动登录远程服务器
摘要:使用 expect 脚本可以实现 SSH 自动登录远程服务器。下面是一个简单的示例: 首先,需要安装 expect 软件包,可以在 Ubuntu 或其他 Linux 发行版中使用以下命令安装: 1 sudo apt-get update 2 sudo apt-get install expect 然
阅读全文
posted @
2023-05-10 23:14
jarsing
阅读(1017)
推荐(0) 编辑