2

I am trying to e-mail a file containing colon (:) character in the name:

my_attachment_name=some_file_with_:_in_the_name.txt
uuencode "${my_attachment_name}" "`basename \"${my_attachment_name}\"`"
     | mail -s "My Report ..." my_email@xyz.com

But, when I receive the e-mail, I see ":" has been removed from the file name.

some_file_with__in_the_name.txt

How can I fixed it?

Thanks.

RGO
  • 4,586
  • 3
  • 26
  • 40

1 Answers1

0

You might try using uuencode with "--encode-file-name". However, here, I'm seeing:

$ uuencode foo:bar.txt foo:bar.txt
begin 664 foo:bar.txt
#:&D*
`
end

which is exactly what I'd want in the "begin" line.

In contrast:

$ uuencode --encode-file-name foo:bar.txt foo:bar.txt
begin-encoded 664 Zm9vOmJhci50eHQ=
#:&D*
`
end

uudecode doesn't require any options to be able to reconstruct foo:bar.txt from Zm9vOmJhci50eHQ= on my computer.

Check the raw content of your email too, it's possible the email client is being stupid. A DOS bias, for example, could make an email client ditch colons.

Alex North-Keys
  • 4,200
  • 1
  • 20
  • 22
  • 1
    : was also the directory separator on classic Mac OS. It may be getting stripped because it's considered generally unportable in file names. – nobody Oct 14 '15 at 10:50
  • Makes sense - the idea of only banning what *has* to be banned from a filename is pretty Unixy (Linux, OS X) - "/" and NUL. – Alex North-Keys Oct 15 '15 at 03:17