I'm afraid there are multiple issues with this. 1. in Bash, you do not use the $ when setting the value of a variable. Also, you don't need to tell it you are setting the value of the variable; you Just Do It.
all="cat list" 2. A "for" loop begins with a "do" command and ends with a "done" command. for x in $all;do 'cat msg2 | mailx -s "Test Message"' $x;done 3. You have single-quotes around 'cat msg2 | mailx -s "Test Message"' which is going to tell Bash to treat the whole string as a single word. There is no command named "cat msg2 | mailx -s "Test Message" that I am aware of. for x in $all;do cat msg2 | mailx -s "Test Message" $x;done 4. I'm not sure this is going to do what you think it's going to do. With these commands, you're telling Bash to send an email to two addresses: "cat" and "list" as specified in the variable $all. I assume you have a file named "list" which you are trying to use the cat command to read. Try this: for x in $(cat list);do cat msg2 | mailx -s "Test Message" $x;done I haven't tested it, so there could be plenty that I've missed. I expect the above should at the very least provide a much more interesting error. :) -wes On Thu, Jul 8, 2010 at 10:30 AM, Rich Shepard <[email protected]>wrote: > When I run this script: > > set $all="cat list" > for x in $all; `cat msg2 | mailx -s "Test Message"' $x > > I see this error: > > -bash: syntax error near unexpected token `cat msg2 | mailx -s "Test > Message"' > > What have I done incorrectly? Is it the semi-colon? > > Typing on two lines (beaking after the semi-colon) makes no difference. > > Rich > _______________________________________________ > PLUG mailing list > [email protected] > http://lists.pdxlinux.org/mailman/listinfo/plug > _______________________________________________ PLUG mailing list [email protected] http://lists.pdxlinux.org/mailman/listinfo/plug
