mailx on ksh revisited


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users mailx on ksh revisited
# 1  
Old 06-28-2007
mailx on ksh revisited

I have read through all documents in FAQ and have run into an issue with sending an email with body message text and an email attachment. I have included what I have thus far and I can get the message body to send in the email to work only. I cannot understand the uuencode even after I read the man pages on it. I am using ksh and it seems a bit strange to me why I cannot get this simple task to work. Please help. I can't get past file not found error. Also can someone explain to me in the following:

uuencode [-m] [infile] remote

what remote means exactly. because I just want to uuencode a file that I have on the server that I am working on. It is the only server I know of. And it took a lot of trial and error to figure out the proper sytax to creat the mailx statement because of the <<-EOF put message here (new line)EOF

Thanks for any help you can provide.

#!usr/bin/ksh -p


base= '/usr/local/ol_inv/daily_ETL/test/';
base1= '/usr/local/ol_inv/daily_ETL/test/testfile.txt';
base2= '/usr/local/ol_inv/daily_ETL/test/msgfile.txt';
base3= '/usr/local/ol_inv/daily_ETL/test/combofile.txt';

print "we are sending the message...";


# uuencode ${base}testfile.txt emailattachr2.txt | cat ${base}testfile.txt ${base}msgfile.txt > ${base}combofile.txt
uuencode testfile.txt emailattacher2.txt | cat testfile.txt msgfile.txt > combofile.txt

mailx -s "Online Financial Reporting - New Users" -r "Tim Kline" tim.kline@company.com <<-EOF

~<${base3}


EOF


echo "email was sent!";





>>>command typed at prompt<<<<
$ ksh mail2_ksh.ksh

>>>resulting output<<<<<<<
mail2_ksh.ksh[4]: /usr/local/ol_inv/daily_ETL/test/: 0403-006 Execute permission denied.
/usr/local/ol_inv/daily_ETL/test/testfile.txt: This: not found.
/usr/local/ol_inv/daily_ETL/test/msgfile.txt: This: not found.
/usr/local/ol_inv/daily_ETL/test/combofile.txt: This: not found.
/usr/local/ol_inv/daily_ETL/test/combofile.txt[3]: This: not found.
we are sending the message...
Interpolate what file?
email was sent!


>>>actaul file paths and permissions<<<
$ pwd
/usr/local/ol_inv/daily_ETL/test
$ ls -l

-rwxr--r-- 1 ol_inv whs 1 Jun 28 14:02 attach.txt
-rwxr--r-- 1 ol_inv whs 312 Jun 28 15:40 combofile.txt
-rwxr--r-- 1 ol_inv whs 884 Jun 28 15:40 mail2_ksh.ksh
-rwxrw-r-- 1 ol_inv whs 208 Jun 28 13:53 msgfile.txt
-rwxrwxrwx 1 ol_inv whs 104 Jun 28 13:56 testfile.txt
# 2  
Old 06-28-2007
Quote:
Originally Posted by tekline
# uuencode ${base}testfile.txt emailattachr2.txt | cat ${base}testfile.txt ${base}msgfile.txt > ${base}combofile.txt
uuencode testfile.txt emailattacher2.txt | cat testfile.txt msgfile.txt > combofile.txt

I would have expected for the output from uuencode to be ignored as cat has been told to copy two files.

Try ....

uuencode testfile.txt >combofile.txt
cat testfile.txt msgfile.tx >>combofile.txt
# 3  
Old 06-29-2007
Some of those error messages are because you have a space after your variable assignments. You are actually trying to run the txt files as scripts.
# 4  
Old 06-29-2007
it's a lot easier than that:


uuencode infile new_name | mailx -s "subject oi" user

oops forgot the message file...


Code:
uuencode infile name | cat message_file - | mailx -vs blah m@blah.com

# 5  
Old 06-29-2007
Thanks for all the help. I still had trouble getting the message inside testfile.txt <<attachment file>> to keep the content inside the file and stay in the attachment format and at the same time put the msgfile inside the email body. So....I figured since I am dealing with MIME type text anyway I will simply cat the file contents directly into the email body like so:

print "we are sending the message...";

cat testfile.txt msgfile.txt >>combofile.txt

cat combofile.txt | mailx -s "Online Financial Reporting - New Users" -r "Tim Kline" tim.kline@company.com


cat combofile.txt

rm combofile.txt

echo "email was sent!";
# 6  
Old 06-29-2007
How do I get the return code (success/failure)? from running the mailx command?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

KSH - mailx - Redirect the undelivered mail

Hi, I need to create one KSH which will send mail to set of recipients using "mailx" command like below. mailx -s "Test mail" "test@yahoo.com, test@gmail.com" <$output.txt The recipients are in different domains (like yahoo, gmail, etc.). My requirement is, if any mail is undelivered,... (1 Reply)
Discussion started by: Matrix2682
1 Replies

2. Solaris

ls display linux style, revisited!!!

hi all, ive downloaded ,built and installed coreutils from sunfreeware.com,in my quest to get the color display when ls is used(linux style)... After the pkg is installed,how do i use ls to get the color? I know its installed because i get a host of cmds that have been updated,l like this, ... (1 Reply)
Discussion started by: wrapster
1 Replies

3. Shell Programming and Scripting

mailx: concatenating strings for message body (KSH)

Hi all, Think this is a pretty simple problem, but I've been thinking about it for a few days. Let's say that I'm going to have to output the contents of a file as the body of a mailx message. I'll probably do this: cat <filename> | mailx <extra commands> However, how do I go about doing... (1 Reply)
Discussion started by: rockysfr
1 Replies

4. Virtualization and Cloud Computing

BAM to SOA - Da? Buzzhype Revisited

Many readers have read the hype, experienced the Orwellian marketspeak, watched the positioning debates, and seen poorly managed software companies play the game of analyst-chasing (similar to ambulance chasing when you think about it). Finally, the up-to-date definitions, and hopefully a bit of... (0 Replies)
Discussion started by: Linux Bot
0 Replies

5. Shell Programming and Scripting

Mailx in shell script (KSH)

Greetings all, I'm pretty new to the use of mailx, having been using mutt most of the time. I'm interested to know how I can use mailx within a shell script to send out a formatted email with the following criterion: 1. My recipient's address is abcdef1000@gmail.com 2. The message body is... (2 Replies)
Discussion started by: rockysfr
2 Replies

6. Shell Programming and Scripting

ksh : using mailx and attachments

Hi I want to use mailx command to send a message included more than one file. I tried to use uuencode in pipe but it could only generate one file. I would avoid using an archive file :p Thanks to read you. Mathieu (2 Replies)
Discussion started by: madmat
2 Replies

7. Solaris

ufsrestore revisited,,

in ufsrestore how do i know which volume my selected folder or file exist?. (4 Replies)
Discussion started by: S26+
4 Replies

8. Solaris

ufsrestore, revisited

I just installed solaris 9 on a sunblade 150(sparc), and have it partitioned. I've been using ufsrestore to restore bring the config from my old system, to the sunblade. I'm not having any luck. The root directory restore seems to work. When I try to restore /usr, I get an "/usr/sbin/fsck not... (4 Replies)
Discussion started by: ECBROWN
4 Replies

9. UNIX for Dummies Questions & Answers

mailx and awk- didn't find an answer KSH

Hi folks, My input file's content: You are line1 You are line2 You are line3 etc... I need to write a script that for every line, it will send an e-mail and the body will hold the line: Output(The e-mail that will be sent): First e-mail: To: aaa Subject: bbb Body:You are line1... (4 Replies)
Discussion started by: hellsd
4 Replies
Login or Register to Ask a Question