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:

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!

I presume the .. is meant to look one directory up? You need the / still.

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.

Hi,

I kept getting the following error:

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

and I typed the following:

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

if you are not sure about the relative path, use absolute i.e. start from /

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:

pwd

Hi All,

This is what I tried and still not working.

[ 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 ]

while you are in practice directory run pwd and post output here

In your example I think it should be:

mail -s "testing" email@hotmail.com < practice/filename

(This assumes that your "ls" is fairly normal and has not been aliased. I only mentioned that because a normal unix "ls" does not put a solidus after the directory name - that would need "ls -p").