I can do this
mailx -s "hello bob" me@world.com <myfile
and I get an email with myfile's content in body.
but I need to store the subject, addresses and file name from in
variables so I can do this
maix -s $subj $emailto < $file
understanding that subject and emailto might have spaces, I store them
with the quotes
so
echo $subj
displays
"hello bob" quotes and all..
Still , I get an error saying bob is an unknown user
|
|
0
|
|
|
|
Reply
|
jobs235 (25)
|
9/8/2007 7:43:49 PM |
|
On Sat, 08 Sep 2007 12:43:49 -0700, jobs wrote:
> "hello bob" quotes and all..
>
> Still , I get an error saying bob is an unknown user
Try using single quotes instead.
|
|
0
|
|
|
|
Reply
|
Dave
|
9/8/2007 7:52:14 PM
|
|
jobs wrote:
> but I need to store the subject, addresses and file name from in
> variables so I can do this
>
> mailx -s $subj $emailto < $file
mailx -s "$subj" "$emailto" < "$file"
|
|
0
|
|
|
|
Reply
|
Oscar
|
9/8/2007 10:31:01 PM
|
|
In article <13e5vbebr0noga2@news.supernews.com>,
Dave Uhring <daveuhring@yahoo.com> wrote:
> On Sat, 08 Sep 2007 12:43:49 -0700, jobs wrote:
>
> > "hello bob" quotes and all..
> >
> > Still , I get an error saying bob is an unknown user
>
> Try using single quotes instead.
That won't work as single quotes don't expand variables.
--
DeeDee, don't press that button! DeeDee! NO! Dee...
|
|
0
|
|
|
|
Reply
|
Michael
|
9/9/2007 12:50:22 AM
|
|
jobs <jobs@webdos.com> writes:
>
>but I need to store the subject, addresses and file name from in
>variables so I can do this
>
>maix -s $subj $emailto < $file
>
>understanding that subject and emailto might have spaces, I store them
>with the quotes
>
Someone else has already posted the short solution, but I want to
mention that your last remark is not a good idea in general.
The better idea is to put quotes where they are needed. In this
case, quotes are needed on the mailx command line. You shouldn't
try to embed extra quotes into the values you put into the variables.
I.e., this is the wrong approach:
subj="'This is a test message'"
emailto="'user1@example.com user2@example.com'"
filename=/path/to/email/file
mailx -s $subj $emailto < $filename
this is the right one:
subj="This is a test message"
emailto="user1@example.com user2@example.com"
filename=/path/to/email/file
mailx -s "$subj" "$emailto" < $filename
So in the lines where you assign values to variables you use only
the quotes necessary for the assignment. Later, when you use the
values on the mailx command line, you use the quotes needed for
the values to be handled properly there. You don't embed extra
quotes in the assignment lines that will take effect on the mailx
command line.
As with all rules, there are exceptions. I.e. situations where you
must embed extra quotes to be used later in the script. However,
they're pretty rare, and your script is not one of them.
-Greg
--
Do NOT reply via e-mail.
Reply in the newsgroup.
|
|
0
|
|
|
|
Reply
|
gerg
|
9/9/2007 3:34:03 AM
|
|
|
4 Replies
620 Views
(page loaded in 0.444 seconds)
Similiar Articles: mailx and variables? - comp.unix.solarisI can do this mailx -s "hello bob" me@world.com <myfile and I get an email with myfile's content in body. but I need to store the subject, address... Crontab Variable - comp.unix.shellmailx and variables? - comp.unix.solaris change subject in cron email - comp.unix.solaris... is sent from a > cron run. Make the commands pipe output into a suitable mailx ... Mailx with attachments - comp.unix.solarismailx and variables? - comp.unix.solaris How to save e-mail or attachment to a file on UNIX OS from the ... I am looking for a script, on unix platform using mailx, to ... Uninitialized variables, why do they equal their name? - comp.lang ...mailx and variables? - comp.unix.solaris Uninitialized variables, why do they equal their name? - comp.lang ... mailx and variables? - comp.unix.solaris I am looking for a ... change subject in cron email - comp.unix.solarismailx and variables? - comp.unix.solaris change subject in cron email - comp.unix.solaris... is sent from a > cron run. Make the commands pipe output into a suitable mailx ... ufsdump root without /var or /usr - comp.unix.solaris... is that SSH for root works without a problem. ... HostbasedAuthentication to "yes" in /usr ... svcadm enable ssh # ps -ef | grep ssh root ... ... environment variable ... Why do some emails take so long to get to me? - comp.sys.mac.apps ...mailx and variables? - comp.unix.solaris I can do this mailx -s "hello bob" me@world.com <myfile and I get an email with myfile's content ... name from in >variables so I ... Remote Execution of Local Code - comp.soft-sys.matlab... output being displayed locally, and where I would have local access to the variables ... MAILX and host/system address setup - comp.sys.hp.hpux Home Director remote - setup ... Can one get wrt54g router to work as nameserver for local network ...Currently I'm looking in the client table to get the current (variable) IP, and then ... MAILX and host/system address setup - comp.sys.hp.hpux Can one get wrt54g router to ... tar: /dev/rmt/0m: Permission denied - comp.unix.solaris... at now + 1 env <CONTROL-D> This will mail you the output, so pick it up with mailx ... You didn't make anything of the different SHELL variable ? No chance at all there's a ... mailxRead mailx commands from an unspecified system start-up file, unless the -n option is given, to initialize any internal mailx variables and aliases. mailx - NOAA Earth System Research LaboratoryThe following environment variables influence the initial value of some mailx internal variables: DEAD, EDITOR, MBOX, LISTER, PAGER, SHELL, VISUAL. 7/23/2012 12:27:43 AM
|