Hello,
I have a shell script. I would like to add email the curl output. I'd appreciate if you help. Thanks.
#!/bin/bash
while read -r URL ; do if [[ ! $(curl -s "$URL"|grep "keyword") ]] ; then echo "keyword changed!!!!"|mail -s "$URL Alert!!!!" info@test.com; fi;done</root/m/url.txt
.
Hello,
it works well but if the keyword not found, I want the curl output to be sent to my email. Thank you very much.
Well, divert the curl output to a file or environmental variable:
curl ... >curl_o 2>curl_e
curl_x=$?
or
curl_oe=$( curl ... 2>&1 ; echo "Curl returned $?." )
Then, you can look at the three outputs and decide who gets what in their email.