I have a input file which has user names and subject.
input
sk7865 /opt/apps/login
sk4888 /opt/apps/info
I am writing a shell script to take inputs from the above file and send a mail.
shell script
#!/bin/bash
while read a b
echo echo ""$a"" | mail -s ""$b"" "$a"@example.com
done < input
In the above script the actual command I wanted to use is:-
echo "hello world" | mail -s "a subject" someone@example.com
I want it to take arguments a,b at hello world , a subject to send the email to someone like I used it in the script. But it is not taking the arguments. I think it is something to do with double quotes. Please provide me with proper script.
You seem to be missing a do
after your while:
#!/bin/bash
while read -r a b
do
echo "$a" | mail -s "$b" "$a"@somewhere.com
done < input
Remember to always run shellcheck on your bash scripts before posting here.
Also, you had an echo echo
in there and double-double-quotes all over the place ""xyz""
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.