mail command in Unix


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting mail command in Unix
# 1  
Old 03-28-2012
mail command in Unix

Hi All,

Is it possible to email a file from another directory in Unix shell prompt? In other words, do we have to be in the directory where the file is located to mail the file?

I was in the Mail directory and my file (filename) is in the Practice directory. I tried this and it didn't work:

Code:
mail -s "test email" email@hotmail.com < ..practice/mail/filename

The file is in Mail, which is in Practice, which is in Unix directory.

Please assist. Thanks!

Last edited by methyl; 03-28-2012 at 06:05 PM.. Reason: please use code tags
# 2  
Old 03-28-2012
I presume the .. is meant to look one directory up? You need the / still.

Code:
mail -s "test email" email@hotmail.com < ../practice/mail/filename

And is that directory named practice or Practice? The difference is important -- filenames and directory names in UNIX are case-sensitive.

Finally, in what way did it not work? The error message can tell you a lot about why.
# 3  
Old 03-28-2012
Hi,

I kept getting the following error:


Code:
../practice/mail/filename: No such file or directory.

and I typed the following:



Code:
mail -s "test email" email@hotmail.com < ../practice/mail/filename


Last edited by methyl; 03-28-2012 at 06:49 PM.. Reason: please use code tags
# 4  
Old 03-28-2012
if you are not sure about the relative path, use absolute i.e. start from /
# 5  
Old 03-28-2012
I agree. If you can't find the file with a ls command then it cannot be used in a mail command.

You know where the file is located in the directory tree.
Please cd to the directory containing the file and post:
Code:
pwd


Last edited by methyl; 03-28-2012 at 06:54 PM..
# 6  
Old 03-28-2012
Hi All,

This is what I tried and still not working.

Code:
[ unix ]ls
practice/

[ unix ]cd practice
[ practice ]ls
mail/  filename

[ practice ]cd ..
[ Unix ]mail -s "testing" email@hotmail.com < /practice/mail/filename
/practice/mail/filename: No such file or directory.

[ unix ]mail -s "testing" email@hotmail.com < /mail/filename
/mail/filename: No such file or directory.

[ unix ]


Last edited by methyl; 03-29-2012 at 09:27 AM.. Reason: please use code tags
# 7  
Old 03-28-2012
while you are in practice directory run pwd and post output here
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX mail command

I am using HP-UX server. I tried to send the email with attachment, I used the below unix command to send with attachment but it doent work. uuencode pepsitoday.csv | mailx -s "csv file" ramkumar15@pepsi.com ---------- Post updated at 02:10 AM ---------- Previous update was at... (2 Replies)
Discussion started by: ramkumar15
2 Replies

2. UNIX for Dummies Questions & Answers

Sending mail in UNIX with body and attachment(.txt) using sendmail command

Hi All, In my .ksh script, I am sending an email with body and attachment (.txt) using sendmail command. I am able to receive the attachement along with the body of the mail. But I am getting special characters along with the content in the .txt. Also the alignment is incorrect. Can you please... (7 Replies)
Discussion started by: KRR
7 Replies

3. UNIX for Advanced & Expert Users

How can I send a mail from my outlook or other mail accounts to UNIX server?

Hi all, I want to send a mail for my business needs from outlook account to an unix server (HP-UX) but I don't send any mail. While I can send from the unix server to my outlook account, I can't send from outlook to unix. How can I achieve this ? How can I send a mail from my outlook or other... (2 Replies)
Discussion started by: igelegin
2 Replies

4. UNIX for Dummies Questions & Answers

Problems using Unix mail command (2)

I recently generated myself the following error when attempting to use the Unix mail command: The flags you gave make no sense since you're not sending mail. There is a recent thread about this issue here in unix.com (with a title very much like this thread's title), but it was closed... (2 Replies)
Discussion started by: Clovis_Sangrail
2 Replies

5. UNIX for Dummies Questions & Answers

Unix mail command internals

Hi all , I wanted to know how does a 'mail' command works in unix. Does it use an smtp server internally ? How and where it is configured then ? I am trying to google out the same , but not getting much help. Any suggestions with be of great help. - Andy (5 Replies)
Discussion started by: anindyabecs
5 Replies

6. Shell Programming and Scripting

keep mail command active inside a script on unix

well, I have a script with this code inside: nohup /usr/sbin/auditstream | /usr/sbin/auditselect -m -e "event== USER_Create || event== USER_Remove || event== USER_Change || event== GROUP_Create || event== GROUP_Remove || event== GROUP_Change || event== PASSWORD_Change " | /usr/sbin/auditpr -h... (4 Replies)
Discussion started by: iga3725
4 Replies

7. UNIX for Dummies Questions & Answers

Problem using unix mail command

Hello, When i am using mail command like this: mail -r prashant.aggarwal@xx.com -s "hiiii" prashant.aggarwal@xx.com < Content.txt i am abl eto dend a mail. Content.txt is a file from which contents are being reda But when i am trying to execute it thru a shell scipt like this it's giving ... (3 Replies)
Discussion started by: cprash.aggarwal
3 Replies

8. UNIX for Dummies Questions & Answers

Mail command in UNIX

1)My main script Calls a function IsDomain to check whether the domain is valid or not PROD>/appl/retek/mpscripts/cat mg3TRn01 #!/bin/ksh # # Standard Header Files # # . ${0%${0##*/}}UKMPFunctionLibrary.test # # START # ScriptStart # # Check that domain exists.Print &... (0 Replies)
Discussion started by: Shilpi
0 Replies

9. UNIX for Dummies Questions & Answers

UNIX mail command

hi, Im trying to send a e-mail to two people e.g X & Y . I run a shell script that uses the mail command to send an email to both these people . The email that i am sending contains two attatchments that i 'add' to a .mail file. mail <recipients> < filename.mail The problem that im... (1 Reply)
Discussion started by: nbvcxzdz
1 Replies

10. Shell Programming and Scripting

E-Mail from command line for UNIX and Perl??

Hi Is there any way to use UNIX and Perl to automate sending e-mail. I got a dynamic changing file that send out to people in my mailing list and want to experinment to see if Perl and UNIX can send it out for me when the content is change. I found a Perl source code but dont really know how to... (4 Replies)
Discussion started by: jy2728
4 Replies
Login or Register to Ask a Question