又用编写脚本任务测试了下:文心一言和讯飞火星都输出的是内网IP,国产还需加油!
测试了一些Prompt,感觉讯飞火星的回答内容和格式和ChatGPT很像。
Prompt: 帮我写一个MacOS查询本机外网IP的shell脚本
#!/bin/bash
ip=$(curl -s ifconfig.me)
echo "Your external IP address is: $ip"
#!/bin/bash
# Filename: get_external_ip.sh
# 使用 curl 获取外网 IP 地址
external_ip=$(curl -s http://ifconfig.me)
# 判断是否成功获取 IP 地址
if [[ -z "$external_ip" ]]; then
echo "获取外网 IP 失败,请检查网络连接。"
else
echo "本机外网 IP 地址: $external_ip"
fi
#!/bin/bash
# 使用curl命令获取外网IP地址
ip=$(curl -s https://api.ipify.org)
# 使用正则表达式提取IP地址
regex='([0-9]{1,3}\.){3}[0-9]{1,3}'
if [[ $ip =~ $regex ]]; then
ip=${BASH_REMATCH[0]}
fi
echo "本机外网IP地址为: $ip"
-
Bard
- Prompt:
Help me write a shell script for querying local public IP addresses on MacOS
#!/bin/bash
# Get the local IP address
local_ip=$(ipconfig getifaddr en0)
# Get the public IP address from ifconfig.me
public_ip=$(curl -s ifconfig.me)
# Print the local and public IP addresses
echo "Local IP address: $local_ip"
echo "Public IP address: $public_ip"
#!/bin/bash
# 使用ifconfig命令查询本机所有接口的IP地址
ip addr show eth0 | grep "inet " | awk '{print $2}'
# 使用ping命令测试本机是否可以访问外网
ping -c 3 google.com
# 输出本机的外网IP地址
ifconfig | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}'
#!/bin/bash
# 获取本机IP地址
ip=$(ifconfig | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}')
# 使用curl命令获取公网IP地址
curl --location --request IP --silent --insecure https://api.ipify.org/?format=json
# 将获取到的公网IP地址输出到终端
echo "本机公网IP地址为:$ip"