LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-28-2013, 09:55 AM   #1
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Rep: Reputation: 0
Angry uuncode doesn't work


Guys

Why this should not work?

simple stuff

(uunecode file1.csv file1.csv ; uunecode file 2.csv file2.csv) | mailx -s "test" testme.com??

What's the problem?

I tried with debug on and I see mail

I tried to change the shell from sh to ksh but still no luck. Fundamentally I don't think there is any issue with my script...
 
Old 08-28-2013, 09:59 AM   #2
Jenni
Member
 
Registered: Oct 2011
Distribution: Slackware, Fedora
Posts: 158

Rep: Reputation: Disabled
Maybe because the command is "uuencode" or "uudecode", not uuncode, or uunecode?
 
Old 08-29-2013, 07:24 AM   #3
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Original Poster
Rep: Reputation: 0
@Jenni

I have typed in correctly in my script. It is uuencode
 
Old 08-29-2013, 07:31 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
@sysmicuser: You need to provide details.

- What doesn't work?
- What did you expect the outcome to be?
- Post the script.
 
Old 08-29-2013, 08:48 AM   #5
Jenni
Member
 
Registered: Oct 2011
Distribution: Slackware, Fedora
Posts: 158

Rep: Reputation: Disabled
Assuming you have mailx set up properly and working, then the line you gave should work, but both files would end up sending as one, which can confuse uudecode if you don't split them up before decoding.
Usually, if you want to send multiple files via uuencode, it is best to make a tarball first ( tar -cvzf file.tar.gz file1 file2 .. fileN ) then encode and send that. then the recipient can use uudecode then tar -xvzf file.tar.gz to extract them.

so:
tar -cvzf file.tar.gz file1 file2 file3 ; uuencode file.tar.gz file.tar.gz
 
Old 08-29-2013, 09:09 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by Jenni View Post
Assuming you have mailx set up properly and working, then the line you gave should work, but both files would end up sending as one, which can confuse uudecode if you don't split them up before decoding.
Usually, if you want to send multiple files via uuencode, it is best to make a tarball first ( tar -cvzf file.tar.gz file1 file2 .. fileN ) then encode and send that. then the recipient can use uudecode then tar -xvzf file.tar.gz to extract them.

so:
tar -cvzf file.tar.gz file1 file2 file3 ; uuencode file.tar.gz file.tar.gz
I agree, that is the solution I would choose, but:
Code:
(uunencode file1.csv file1.csv ; uunencode file2.csv file2.csv) | mailx -s "test" testme.com
Will work. I do assume that mail is set up properly and testme.com is a valid e-mail address.

A test shows this:
Code:
$ ( uuencode foobar foobar ; uuencode fubar fubar ) | mailx -s test druuna
$ mail
Mail version 8.1.2 01/15/2001.  Type ? for help.
"/var/mail/druuna": 1 message 1 new
>N  1 druuna@plains.wil  Thu Aug 29 16:04   23/649   test
& 
Message 1:
From druuna@plains.wildfire.nl Thu Aug 29 16:04:55 2013
Envelope-to: druuna@plains.wildfire.nl
Delivery-date: Thu, 29 Aug 2013 16:04:55 +0200
Date: Thu, 29 Aug 2013 16:04:55 +0200
To: druuna@plains.wildfire.nl
Subject: test
From: druuna <druuna@plains.wildfire.nl>

begin 640 foobar
.,0HR"C,*-`HU"C8*-PH`
`
end
begin 640 fubar
080IB"F,*9`IE"F8*9PIH"@``
`
end

&

Last edited by druuna; 08-29-2013 at 09:11 AM. Reason: Fixed typo.
 
Old 08-30-2013, 08:39 AM   #7
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Original Poster
Rep: Reputation: 0
@drunna.

I don't think there is any wrong in my script. I just ran the same command online on unix console and seems to be working fine but I have no idea why it doesn't work within my shell script
 
Old 08-30-2013, 08:41 AM   #8
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by sysmicuser View Post
I don't think there is any wrong in my script. I just ran the same command online on unix console and seems to be working fine but I have no idea why it doesn't work within my shell script
If you don't post the script here, we cannot help you.

You mention Unix; On what platform are you trying to do this?
 
1 members found this post helpful.
Old 08-30-2013, 08:48 AM   #9
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Original Poster
Rep: Reputation: 0
@drunna

Yes I am posting code mate, night time here so that is why brain is working slow

Code:
[oracle@rhel53 temp]$ cat script1.sh 
#!/bin/bash

set -x

day=$(date +%A)
date_format=$(date +%d-%b-%Y)
password=$(/app/oracle/decrypt.sh <encrypted-password>)
report_1=script1-part-1_${date_format}.csv
report_2=script1-part-2_${date_format}.csv
export TNS_ADMIN=<path to tns names .ora>
if [ "$day" == "Monday" ] 
then
        echo -e "Do whatever you want"
else
sqlplus -s user/$password@database << EOF >> $report_1
@script1-part1-mon.sql
EOF

sqlplus -s user/$password@database << EOF >> $report_2
@script1-part-2-mon.sql
EOF
fi

(uuencode $report_1 $report_1 ; uuencode $report_2 $report_2) | mailx -s "Test Report" user@test.com
#rm -vf ${report_1}
#rm -vf ${report_2}

echo "I have done all my work"
[oracle@rhel53 temp]$
I have tried in all different shell but don't know why it doesn't works !

I tried the same on command line and it indeed works beautifully

---------- Post added 08-30-13 at 11:49 PM ----------

@Jenni

No need to tar. We can attach multiple files in a single email.
 
Old 08-30-2013, 09:04 AM   #10
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
@sysmicuser: The script doesn't generate any output at all when you execute it?

When using set -x there should be output generated, please post this.

On first glance I don't see anything wrong (I'm not a DB man and I assume the sql parts are correct). Only thing that I would call suspicious is the old redhat version (5.3), this should be 5.9 as of 2013.
 
Old 08-30-2013, 09:08 AM   #11
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Original Poster
Rep: Reputation: 0
@druna

Script generates output. It generates two csv files but they are not sent as an attachment !! Yep, the sql parts are fine. I have no idea why it is not sent as an attachment.

Yep posting output.

Last edited by sysmicuser; 08-30-2013 at 09:11 AM.
 
Old 08-30-2013, 09:12 AM   #12
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by sysmicuser View Post
Script generates output. It generates two csv files but they are not sent as an attachment !! Yep, the sql parts are fine. I have no idea why it is not sent as an attachment.
I'm not talking about the files that are generated by the script. I'm talking about the output generated by set -x, which would look something like this:
Code:
$ ./script1.sh
++ date +%A
+ day=vrijdag
++ date +%d-%b-%Y
+ date_format=30-aug-2013
.
.
.
Post that, please.
 
1 members found this post helpful.
Old 08-30-2013, 09:20 AM   #13
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Original Poster
Rep: Reputation: 0
Unhappy

Code:
[oracle@script1 temp]$ ./script1.sh 
++ date +%A
+ day=Saturday
++ date +%d-%b-%Y
+ date_format=31-Aug-2013
++ /app/oracle/decrypt.sh <encrypted password>
+ password=<password>
+ report_1=script1-part-1_31-Aug-2013.csv
+ report_2=script1-part-2_31-Aug-2013.csv
+ export TNS_ADMIN=<path to tnsnames.ora>
+ TNS_ADMIN=<path to tnsnames.ora>
+ '[' Saturday == Monday ']'
+ sqlplus -s user/user99@database
+ sqlplus -s user/user99@database
+ uuencode script1-part-1_31-Aug-2013.csv script1-part-1_31-Aug-2013.csv
+ mailx -s 'Test Report' user@test.com
+ uuencode script1-part-2_31-Aug-2013.csv script1-part-2_31-Aug-2013.csv
+ echo 'I have done all my work'
I have done all my work
[oracle@script1 temp]$
 
Old 08-30-2013, 09:28 AM   #14
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
The above looks fine.

I'm starting to wonder what you mean by attachment.

- Did you look inside the mail send to user@test.com?
- Do you see anything that resembles the following inside:
Code:
begin 640 script1-part-1_31-Aug-2013.csv
<unreadable stuff>
end
begin 640 script1-part-2_31-Aug-2013.csv
<unreadable stuff>
end
 
1 members found this post helpful.
Old 08-31-2013, 08:45 PM   #15
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Original Poster
Rep: Reputation: 0
Unhappy

@druna

Apologies for the delay in response.
I say attachment means I say that I am not getting email with those two files.
Yes I looked in the email there is nothing in that.

Quote:
begin 640 script1-part-1_31-Aug-2013.csv
<unreadable stuff>
end
begin 640 script1-part-2_31-Aug-2013.csv
<unreadable stuff>
end
Instead of 640 I see 700 because I have explicitly changed the permissions. yes I could see like that, why you ask? Is that the reason it is unable to send an attachment?

Further investigation reveals that even if I do something like this

uuencode file1.csv file1.csv|mailx -s "test" user@test.com

I am not getting email at all? However same email can be sent "outside" the shell script. I did echo $? just after this command and get return code as 0 ! all confusing

Last edited by sysmicuser; 08-31-2013 at 09:02 PM.
 
  


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
totem-pps plugin doesn't seem to work (doesn't show up) prushik Linux - Software 1 07-29-2013 09:51 AM
Google Hangout doesn't work, and Mplayer doesm't work without -ao alsa flagGoogle H ranban282 Linux - Software 0 02-20-2012 04:23 AM
Keyboard doesn't work right click on mouse doesn't work ramblinrick Linux Mint 2 10-15-2010 01:10 AM
DNS lookup doesn't work, ping, firefox will not work properly lovemov Linux - Networking 2 04-23-2009 02:30 PM
logout in x doesn't work and nvidia doesn't boot Meriadoc Linux - Newbie 2 06-18-2004 12:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:47 AM.

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