[英]Bash Script to read file and curl on each line and output if string found
Trying to build a shell script which determines if the site is using PulseVPN or not.尝试构建一个 shell 脚本来确定该站点是否正在使用 PulseVPN。 The script takes a input file which contains a list of URLs, iterate each URL line by line, perform cURL operation and grep for specific string.
该脚本采用一个包含 URL 列表的输入文件,逐行迭代每个 URL,执行 cURL 操作和 grep 特定字符串。 And if string found, display a echo message "Website using PulseVPN"
如果找到字符串,则显示回显消息“使用 PulseVPN 的网站”
Here is my code -这是我的代码 -
Keyword="dana-na" # keyword to find for PulseSecure SSL VPN
while read -r line;
do
if curl -s -L "$line" | grep "$keyword" > /dev/null
then
# if the keyword is in the conent
echo " The website $line is using Pulse Secure VPN"
else
echo "Pulse Secure VPN Not Found on $line"
fi
done < urls.txt
Problem The code is working but The problem here is when i include only one URL in input file.问题代码运行正常,但这里的问题是当我在输入文件中只包含一个 URL 时。 It gives correct result.
它给出了正确的结果。 But if i include more than one URL in input file, then it gives incorrect results.
但是如果我在输入文件中包含多个 URL,那么它会给出不正确的结果。 Can anyone explains why is this happening.
任何人都可以解释为什么会发生这种情况。 Is anything wrong in code ?
代码有什么问题吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.