LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Shel script mail send ("/" in mail address) problem (http://www.linuxquestions.org/questions/linux-networking-3/shel-script-mail-send-in-mail-address-problem-356084/)

anaid 08-23-2005 06:07 AM

Shel script mail send ("/" in mail address) problem
 
Have to send mail using bash or sh (Suse 8.2 )

input:
mail -s test -a text.txt test.try/good@go.com < empty.txt

output:
test.try/good@go.com: No such file or directory



the problem is "/" .

i still want use it , but how to fix it?

scowles 08-23-2005 07:46 AM

First, Is the mail command you are executing a shell script that you wrote? I don't see that -a is a supported command line argument for the mail command.

Second, my interpretion of your error is the space between the test.txt and test.try is giving you problems, not the slash.

With the above in mind, if you are wanting a shell script to treat the value of an argument separated with spaces as a single argument, then enclose the value of the argument in either double-quotes (expansion) or single-quotes (no expansion). Example:

mail -s test -a 'text.txt test.try/good@go.com' < empty.txt

-or-

email='test.txt test.try good@go.com'
mail -s test -a "${email}" < empty.txt

If your goal is to escape the meaning of a shell metacharacter or control character, then prefix that character with a whack \. BTW: I don't see that slash / is a shell metacharacter. But using your example:

mail -s test -a "text.txt test.try\/good@go.com" < empty.txt

anaid 08-23-2005 08:19 AM

im using Suse 8.2
it uses nail


NAIL(1) User Commands NAIL(1)



NAME
nail - send and receive MIME conformant mail

SYNOPSIS
nail [-BFintv~] [-s subject] [-a attachment ] [-c cc-addr]
[-b bcc-addr] [-r from-addr] [-h hops] to-addr ...

nail [-BeHiInNv~] [-T name] -f [name]

nail [-BeinNv~] [-u user]

DESCRIPTION
Nail is an intelligent mail processing system, which has a
command syntax reminiscent of ed(1) with lines replaced by
messages. It is based on Berkeley Mail 8.1, is intended
to provide the functionality of the POSIX.2 mailx command,
and offers extensions for MIME messages, POP3 and SMTP.

scowles 08-23-2005 08:41 AM

Thanks for the clarification about the mail command you are using, but did enclosing the attachment argument (-a) within single quotes fix your error message?


All times are GMT -5. The time now is 05:03 AM.