我想编写一个 Bourne shell 脚本,以机器名称作为参数并显示一条消息,告知您主机是否在本地网络上
答案1
ping -c 1 -t 5 a_machine_name >> /dev/null && echo "该机器在局域网上" || echo "该机器未连接到局域网"
答案2
#!/bin/bash
echo Please enter host you would like to ping:
read PING
ping "$PING"
我想编写一个 Bourne shell 脚本,以机器名称作为参数并显示一条消息,告知您主机是否在本地网络上
ping -c 1 -t 5 a_machine_name >> /dev/null && echo "该机器在局域网上" || echo "该机器未连接到局域网"
#!/bin/bash
echo Please enter host you would like to ping:
read PING
ping "$PING"