[Solved] Help -file archival


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [Solved] Help -file archival
# 8  
Old 02-06-2014
if file are of any extension just try
Code:
for file in *;do
  ........
  ...your command  goes here..
  ........
done

# 9  
Old 02-06-2014
Try this:
Code:
DT=$( date +"%Y%m%d" )

for file in DIR_A/*.*
do
        [ -d "$file" ] && continue
        fname="${file##*/}"
        extns="${file##*.}"
        echo mv "$file" "DIR_B/${fname%.*}${DT}.${extns}"
done

Remove echo if output looks good.
# 10  
Old 02-06-2014
Thanks Yoda for your quick Help .

It worked perfectly .

Now All the files in
Code:
"DIR_B/${fname%.*}${DT}.${extns}"

Need to be sent as an email attachment .

I use the following code but seems to have unexpected error . Request your pair of eyes

Code:
EFILES="DIR_B/${fname%.*}${DT}.${extns}"

uuencode "$EFILES" "$EFILES"| mail -s "HI" $MailGrp

# 11  
Old 02-06-2014
Quote:
Originally Posted by AspiringD
I use the following code but seems to have unexpected error
What unexpected error?
# 12  
Old 02-07-2014
Hi Yoda ,
Please find the below error
Code:
uuencode: DIR_B/20140206.: Unknown system error

---------- Post updated 02-07-14 at 09:50 AM ---------- Previous update was 02-06-14 at 09:41 PM ----------

I also tried below but no luck. Please help

Code:
 uuencode FOLDER/t.txt log.txt | mailx -m -s "file- hi" $EMAIL
mailx: illegal option -- m
Usage: mailx [-BDFintv~] [-s subject] [-a attachment ] [-c cc-addr] [-b bcc-addr]
             [-r from-addr] [-h hops] [-A account] [-R reply-addr] to-addr ...
       mailx [-BDeHiInNRv~] [-T name] [-A account] -f [name]
       mailx [-BDeinNRv~] [-A account] [-u user]

And sometimes using uuencode function i am only getting email body as

Code:
begin 644 t.txt
"=`H`
`
end

But no attachment
# 13  
Old 02-07-2014
Use sendmail instead:
Code:
{
        echo "From: fr_addr@domain.com"
        echo "To: to_addr@domain.com"
        echo "MIME-Version: 1.0"
        echo "Subject: Your email subject here"
        echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"'
        echo "---q1w2e3r4t5"

        echo "Content-Type: text/plain"
        echo "Content-Disposition: inline"
        echo '---q1w2e3r4t5'
        echo "Your email body here"
        echo '---q1w2e3r4t5'

        echo "Content-Type: text/plain; charset=US-ASCII; name=log.txt"
        echo "Content-Disposition: attachment; filename=log.txt"
        echo '---q1w2e3r4t5'
        cat /absolute_path/log.txt
        echo '---q1w2e3r4t5--'
} | /usr/sbin/sendmail -t

# 14  
Old 02-07-2014
Hi Yoda,
I tried this too but i am getting only blank email attachment .My file can be of any type , i tried for .csv.
When i tried below code for txt
Code:
    echo "From: $EMAIL"
>         echo "To : $EMAIL"
>         echo "MIME-Version: 1.0"
>         echo "Subject: Error File"
>         echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"'
>         echo "---q1w2e3r4t5"
        echo "Content-Type: text/plain; charset=US-ASCII; name=t.txt"
>
>
>         echo "Content-Type: text/plain; charset=US-ASCII; name=t.txt"
>         echo "Error File: attachment; t.txt"
>         echo '---q1w2e3r4t5'
>         cat Folder/t.txt
>         echo '---q1w2e3r4t5--'
> } | /usr/lib/sendmail -t

I am getting the attachment as ATT00001.txt and output as hello brother---q1w2e3r4t5--

Last edited by AspiringD; 02-07-2014 at 12:20 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] File reformat

I am using the code below to reformat the input (hp.txt). The output (newhp.txt) is not in the desired format and I can not seem to figure it out. I have attached both. Thank you. perl -aF/\\t/ -lne 'print join(" ",@F) for ("0 A","0 G","0 C","0 T","A 0","G 0","C 0","T 0")' hp.txt > newhp.txt ... (4 Replies)
Discussion started by: cmccabe
4 Replies

2. UNIX for Dummies Questions & Answers

[Solved] Assign file name = to string in a different file

I have two files: pgmname.ou1 - contains invoice data pgmname.ou2 - contains unique file name for pgmname.ou1 I want to copy pgmname.ou1 to a file with the name specified in pgmname.ou2. So if pgmname.ou2 has a line in it with the following data: FILE.NAME.UNIQUE.csv I want to: cpy... (2 Replies)
Discussion started by: rjjv0208
2 Replies

3. Shell Programming and Scripting

[solved] File type error (not a regular file)

Hi friend, i have written script as below to check the file existance. but i got error path="/k/p1100/users/jewel/Output" FILENAME=`ls -lrt $path/*HT|tail -1|cut -d "/" -f 8` if ; then echo "$FILENAME is available " chmod 755 $path/$FILENAME /usr/bin/scp... (0 Replies)
Discussion started by: Jewel
0 Replies

4. UNIX for Dummies Questions & Answers

[Solved] New Line in file

Hi, Though I was successful in following query, I like to know the other ways of doing it. I have a file that is sent as an attachment via mail. However, while opening it, notepad does not recognize new line character whereas other editors like text pad recognizes new line character of unix.... (2 Replies)
Discussion started by: bobbygsk
2 Replies

5. Programming

[Solved] Removing duplicates from the file and saving as new file

Dear All I have 200 data files and each files has many duplicates. I am looking for the automated awk script such that it checks and removes the duplicates from the each file and saving them as new files for all 200 files in the respective folder. For example my data looks like this.. ... (12 Replies)
Discussion started by: bala06
12 Replies

6. Shell Programming and Scripting

[Solved] Need help formatting a file

I have a report similar to the below: ^L"0.1","Run Date : 19/11/10 Navneet Bank, N.A. PAGE NO : 1" "0.2",Proc Date : 19/11/10 GLOBAL A/C SYSTEM ... (2 Replies)
Discussion started by: Gangadhar Reddy
2 Replies

7. Shell Programming and Scripting

small error in shellscripting -archival part

Hi All, I have run the below script but getting one small error. please help me to solve this. ERROR: tar: Error exit delayed from previous errors CODE: #! /bin/bash CEP=/home/user01/exercise/CEP ARCH=/home/user01/exercise/archive LOG=/home/user01/exercise/logs... (3 Replies)
Discussion started by: aish11
3 Replies

8. Shell Programming and Scripting

[solved] merging two files and writing to another file- solved

i have two files as file1: 1 2 3 file2: a b c and the output should be: file3: 1~a 2~b 3~c (1 Reply)
Discussion started by: mlpathir
1 Replies

9. UNIX for Dummies Questions & Answers

Archival Tool for UNIX

Hi All, Need to get the information if there is any tool on Unix for Archiving and retrival of documents automatically. Having the capbalilty to integrate with other systems. And provide the APIs which can be called from other Systems to facilitate automatic Archival and Retrieval. Thanks &... (7 Replies)
Discussion started by: sanjeev0915
7 Replies
Login or Register to Ask a Question