LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 09-22-2011, 06:02 AM   #1
Sha_unix
Member
 
Registered: Sep 2011
Posts: 46

Rep: Reputation: Disabled
Question zip + attach sending to mail from solaris box.


Hi,i am not finding any command to mail myself with attached csv/txt file. i used below commands but got unwrapped/grambled text as a mail.

$ (uuencode reports.csv reportscsv) | mailx -s "My Report" user@yourcorp.com

( if possible i want to zip and send 3 files of same size (35k).

Can anybody help.
 
Old 09-22-2011, 08:49 AM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
If you make a little shell program
Code:
#!/bin/ksh
cat ${1} | uuencode "${1}" | mailx -[b|c] you@where.what -s ${1} whoever@where.what
Call it, say, mailit.sh and make mailit then
Code:
mailit file
"file" can be zipped, gzipped, plain text, PostScript, PDF, whatever (so you can send anything as an attachment).

Or, you can
Code:
#!/bin/ksh
zip ${1}.zip ${1}
cat ${1}.zip | uuencode "${1}.zip" | mailx -[b|c] you@where.what -s ${1}.zip whoever@where.what
rm ${1}.zip
The -b argument is "blind copy" (your address does not appear in the CC list) or -c your address does appear in the CC list.

You can go further and loop through a list of file if you want to do that.

Hope this helps some.
 
Old 09-22-2011, 09:05 AM   #3
Sha_unix
Member
 
Registered: Sep 2011
Posts: 46

Original Poster
Rep: Reputation: Disabled
Thank you Tronayne,

i used your first code seems working, but i got attachment properly but file is not intact, the lines are all grambled. and csv file is totally messed up. Do we have any option for that...
 
Old 09-22-2011, 12:56 PM   #4
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
Well, I dunno -- I just sent the file mailit.sh to myself at both gamil.com and my local machine (note that mailx does not like dealing with zipped files and the attachment will be unreadable -- with a mail app, like Thunderbird, the attachment can be saved and unzipped). Note that zipping means that the attachment will be mailto.sh.zip, not just mailto.sh.

Hope this helps some.
 
Old 09-26-2011, 04:59 AM   #5
Sha_unix
Member
 
Registered: Sep 2011
Posts: 46

Original Poster
Rep: Reputation: Disabled
Can anybody help on this.. This seems to be not working (as i get attachment grambled when i open it)
 
Old 09-26-2011, 07:31 AM   #6
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
OK, take a look at the man page for mailx -- is there a -a option? If so, that's how to do an attachment. The "old" mailx on Solaris didn't support attachments (no -a) and the uuencode I gave would work with that but not, apparently, with a mailx that does have the -a option. Sigh.

So, if you do have a newer mailx that has the -a, you do it like this
Code:
#       we need to zip the file
#       get the filename without any path information
FILE=`basename ${1}.zip`
#       zip it
#       (otherwise use gzip -c ${1} > ${FILE}.gz)
zip ${FILE} ${1}
#       compose a little message
echo "Attached is ${FILE}." > /tmp/message
mailx -a ${FILE} -c who@where -s "Here is ${FILE}" who@where < /tmp/message
rm ${FILE} /tmp/message
And that works.

Hope this helps some.
 
Old 09-26-2011, 07:42 AM   #7
Sha_unix
Member
 
Registered: Sep 2011
Posts: 46

Original Poster
Rep: Reputation: Disabled
I have older version of SUN.

code:
SunOS noszprrsnp01 5.10 Generic_144488-14 sun4u sparc SUNW,Netra-T12

 
Old 09-26-2011, 12:50 PM   #8
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
Well, that ought to work -- but, seems like I remember (it's been a while) that zip wasn't all that hot on Solaris... do you have gzip available (and, of course, does whoever you're sending to?).

I fiddled with it some some and got it to actually work like it would on Solaris with
Code:
#       we need to zip the file
#       get the filename without any path information
FILE=`basename ${1}`
#       zip it
#       (otheriwise us gzip -c ${1} > ${FILE}.gz)
zip ${FILE}.zip ${1}
#       compose a little message
echo "Attached is ${FILE}.zip." > /tmp/message
cat ${FILE}.zip | uuencode ${FILE}.zip | mailx -s "Here is ${FILE}.zip" -c who@where sombody@somwhere < /tmp/message
rm ${FILE}.zip /tmp/message
Realize that you will not be able to deal with the attachment in mailx -- gotta use Thunderbird or some other web-based mail client.

I've mailed three different CSV files to myself, got 'em in Thunderbird, upzipped them and got back what I expected.

This is about the only thing I can think of to do other than, maybe, use Thunderbird as your mailer and attach pre-zipped (or gzipped) files using it from your Solaris box. Thunderbird does (or at least is used to) build on Solaris and that might be an answer (might even be a Solaris package for it).

Hope this helps some.
 
Old 09-26-2011, 03:30 PM   #9
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by tronayne View Post
Thunderbird does (or at least is used to) build on Solaris and that might be an answer (might even be a Solaris package for it).
Thunderbird is included in Solaris 10 update 4 (August 2007) and newer.
Otherwise, many builds are downloadable from here http://www.sunfreeware.com/mozilla.html
 
Old 09-27-2011, 02:16 AM   #10
Sha_unix
Member
 
Registered: Sep 2011
Posts: 46

Original Poster
Rep: Reputation: Disabled
Thank you very much Tronayne and Jilliagre .
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error during sending mail from solaris 9 smartgupta Solaris / OpenSolaris 2 08-10-2009 09:28 PM
Linux box (Debian) not sending e-mail eysikal Linux - Newbie 5 09-18-2007 11:59 PM
Sending mail from linux box alex360 Linux - Newbie 2 07-08-2005 10:56 AM
Sending fax from a remote box via e-mail ricky_ds Linux - Networking 0 11-11-2004 09:23 AM
How do I zip and attach the output data of a grep | awk | mail shell script? 360 Programming 1 05-08-2002 08:26 AM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 09:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration