Mailing files with, ls filtered with grep


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Mailing files with, ls filtered with grep
# 1  
Old 01-27-2009
Mailing files with, ls filtered with grep

Hi guys

Im new to forum so please dont be hard to me if I make any mistakes Smilie

I want to the following task:

1. I have a file lets say file1, which contains job names with numbers which have failed to start and ....
I can sort that file into another to get only the Job numbers with awk
the file1 looks like this
>cat file1
O575757.*
O262628.*

2. I want to send also the whole log from the jobs that have failed in a attachement in a mail.
want do to something like
for i in `ls /log_path/date/ | !!! need to specify the grep so that i will give output of those files with the names from file1`
then goes
do
uuencode $i $i
done | mailx -s "Files" mymail@company.com

!!! Point is I dont know how to apply the pattern for ls do echo only the that match from the file1

I will appreciate any help

Thank you in advance
# 2  
Old 01-27-2009
Quote:
Originally Posted by kl1ngac1k
Hi guys

Im new to forum so please dont be hard to me if I make any mistakes Smilie

I want to the following task:

1. I have a file lets say file1, which contains job names with numbers which have failed to start and ....
I can sort that file into another to get only the Job numbers with awk
the file1 looks like this
>cat file1
O575757.*
O262628.*

2. I want to send also the whole log from the jobs that have failed in a attachement in a mail.
want do to something like
for i in `ls /log_path/date/ | !!! need to specify the grep so that i will give output of those files with the names from file1`
then goes
do
uuencode $i $i
done | mailx -s "Files" mymail@company.com

!!! Point is I dont know how to apply the pattern for ls do echo only the that match from the file1

I will appreciate any help

Thank you in advance

Hello in the mean time I have made some progress so this is how it should work

#!/usr/bin/ksh
set -x
homedir="/home/martin/test"
datum="2009.01.27"
premena=`cat ${homedir}/file1`
echo $premena
export homedir datum premena
(for file in `ls ${homedir}/${datum} | grep "$premena"`
do
uuencode "$file" "$file"
done) | mailx -s "subory" martin@localhost

dont know way but I have some errors also after that that I have installed shareutils for uuencode, getting an error uuencode fopen-ing

Has somethis problem, if yes did U manage to fix it?
# 3  
Old 01-27-2009
not tested....
Code:
#!/usr/bin/ksh
set -x
homedir='/home/martin/test'
datum='2009.01.27'

   while read file
   do
      for i in ${homedir}/${datum}/${file}
      do
         (uuencode "$i" "$i" ) | mailx -s "subory" martin@localhost
      done
   done < ${homedir}/file1

# 4  
Old 01-27-2009
Computer

Hi vgersh99

Thxs a lot its working now Smilie, gonna try that out right this morning.

Can I ask why did it didnt worked my way?

Thank you again vgersh99
Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Content should be filtered within brackets

Hello all, I have a string and would like to extract the content of the text within the brackets. Here is the string: Desc="file from to line" What I would like to have is the following: Filename="4009821_737498.out" FromLine=12965 ToLine=12355 Maybe I have to do this with... (6 Replies)
Discussion started by: API
6 Replies

2. Shell Programming and Scripting

Content of filtered files write as columns into one file

Hi everybody! i have a lot of files where i filter out data. #!/bin/bash f=sample_*.Spe for i in $f `eval echo ls sample_*.Spe` do if test -f "$i" then awk 'FNR==8 ||FNR==10 || (FNR>=13 && FNR<=268) {print $1}' $i > test$i.txt paste test$i.txt test_f.txt > test_f.txt ... (5 Replies)
Discussion started by: IMPe
5 Replies

3. Shell Programming and Scripting

Python - glob () - How to grep same files with different extension files

Hi I Have a directory and i have some files below abc.txt abc.gif gtee.txt ghod.pid umni.log unmi.tar How can use glob function to grep abc files , i have created a variable "text" and i assigned value as "abc", please suggest me how can we use glob.glob( ) to get the output as below... (2 Replies)
Discussion started by: kumar85shiv
2 Replies

4. UNIX for Advanced & Expert Users

Regarding mailing of logs

Hi Folks, I have an application which logs get continuously refreshed and made after every 1 second , I want that those logs get mailed to me at my email id sara@somewhere.com The location is cd /var/log/abc/log Please advise the command so that I can mail abc.log at my mailid inbox... (2 Replies)
Discussion started by: SankalpS
2 Replies

5. Shell Programming and Scripting

grep the process id and kill all the filtered process

Hi I want to write a shell script which can find the process id's of all the process and kill them eg: ps ax | grep rv_ 3015 ? S 0:00 /home/vivek/Desktop/rv_server 3020 ? S 0:00 /home/vivek/Desktop/rv_gps 3022 ? S 0:00 /home/vivek/Desktop/rv_show ... (7 Replies)
Discussion started by: vivek_naragund
7 Replies

6. Shell Programming and Scripting

grep for certain files using a file as input to grep and then move

Hi All, I need to grep few files which has words like the below in the file name , which i want to put it in a file and and grep for the files which contain these names and move it to a new directory , full file name -C20091210.1000-20091210.1100_SMGBSC3:1000... (2 Replies)
Discussion started by: anita07
2 Replies

7. Shell Programming and Scripting

perl script for listing files and mailing the all files

Hi, I am new to perl: I need to write perl script to list all the files present in directory and mail should be come to my inbox with all the files present in that directory. advanced thanks for valuable inputs. Thanks Prakash GR (1 Reply)
Discussion started by: prakash.gr
1 Replies

8. Shell Programming and Scripting

Please help: Extract filtered output from following input

Following is input: <P align="justify" ><FONT size="+1" color="#221E1F">the tiny bundles of hairs that protrude from them. Waves in the fluid of the inner ear stimulate the hair cells. Like the rods and cones in the eye, the hair cells convert this physical stimulation into neural im<FONT... (1 Reply)
Discussion started by: parshant_bvcoe
1 Replies

9. Shell Programming and Scripting

CSV Table Filtered/transposed/matched using CSH

Hello Everybody: I have a csv file that i would want to be converted to a table (csv also) filtered, transposed and matched with the header (quite confusing, sorry). So the output can used on a spreadsheet and plot on a grap. I'm using CSH on unix. To further explain, here is an example input... (2 Replies)
Discussion started by: elmer1503
2 Replies

10. UNIX for Dummies Questions & Answers

Filtered Print Que

I'm a new support employee and 1 of my sites is having a problem printing. There is a UnixWare 2.0 server and a HPLJ printer connect by TCP/IP. When a user prints something it usually prints but the job stays on the que for a while after it has been printed. When I check 'lpstat -t' the job is... (2 Replies)
Discussion started by: cparks
2 Replies
Login or Register to Ask a Question