read file and output message


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting read file and output message
# 8  
Old 01-24-2007
Quote:
Originally Posted by happyv
what do you mean? I changed {} to () ....but still not work.
Move mailx command out of awk command
Code:
awk ' /is missing/ { flag=1;print > "baby_missing.txt" }
END { 
if( flag != 1 ) 
print "no file is missing in system" > "baby_nomissing.txt" 
} ' baby.txt
mailx -c "`cat ccfile.txt`" -s \'"Missing tap file status $today'" "`cat tofile.txt`" < missing.msg

or if you want to execute within awk use system function
Code:
system("mailx ...")

# 9  
Old 01-24-2007
Quote:
Originally Posted by anbu23
Move mailx command out of awk command
Code:
awk ' /is missing/ { flag=1;print > "baby_missing.txt" }
END { 
if( flag != 1 ) 
print "no file is missing in system" > "baby_nomissing.txt" 
} ' baby.txt
mailx -c "`cat ccfile.txt`" -s \'"Missing tap file status $today'" "`cat tofile.txt`" < missing.msg

or if you want to execute within awk use system function
Code:
system("mailx ...")

if i put the mailx out of awk, the mail will be send out whatever it's missing or not.
I just want to send mail if the baby_missing.txt exist..
# 10  
Old 01-24-2007
Add this code after the awk code
Code:
if [ -s "baby_missing.txt" ]
then
   mailx ...
fi

# 11  
Old 01-24-2007
Quote:
Originally Posted by anbu23
Add this code after the awk code
Code:
if [ -s "baby_missing.txt" ]
then
   mailx ...
fi

what do you mean after? After the whole code below?

awk ' /is missing/ { flag=1;print > "baby_missing.txt" }
END {
if( flag != 1 )
print "no file is missing in system" > "baby_nomissing.txt"
} ' baby.txt
if [ -s "baby_missing.txt" ]
then
mailx ...
fi
# 12  
Old 01-24-2007
what you did is correct
# 13  
Old 01-24-2007
Quote:
Originally Posted by anbu23
what you did is correct
yes...it correct. thx!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to read each line from input file, assign variables, and echo to output file?

I've got a file that looks like this (spaces before first entries intentional): 12345650-000005000GL140227 ANNUAL HELC FEE EN 22345650-000005000GL140227 ANNUAL HELC FEE EN 32345650-000005000GL140227 ANNUAL HELC FEE EN I want to read through the file line by line,... (6 Replies)
Discussion started by: Scottie1954
6 Replies

2. Shell Programming and Scripting

Read file from input and redirect to output file

Hi , i am having an file which contains 5 file_name data, i need to read the file name and will perform certain operation and generate out file names with named as 5 individual file_names for eg: file.txt contains file_name1.txt|hai file_name2.txt|bye file_name3.txt|how... (3 Replies)
Discussion started by: rohit_shinez
3 Replies

3. Shell Programming and Scripting

Read file and for each line replace two variables, add strings and save output in another file

Hi All, I have a file, let's call it "info.tmp" that contains data like this .. ABC123456 PCX333445 BCD789833 I need to read "info.tmp" and for each line add strings in a way that the final output is put /logs/ua/dummy.trigger 'AAA00001.FTP.XXX.BLA03A01.xxxxxx(+1)' where XXX... (5 Replies)
Discussion started by: Andy_ARG
5 Replies

4. UNIX for Dummies Questions & Answers

How to read entire output from a file?

Hello- I am trying to view a file which is quite large. However, whenever I do 'cat (file name)' it shows me just the half.. I am using Putty to access my server. Also, is it possible to edit a file from a unix system on a 'Gedit for Windows" text editor? Thanks (7 Replies)
Discussion started by: DallasT
7 Replies

5. Shell Programming and Scripting

How to read file and only output certain content

Hi - I have a file containing data like :- cn=tommy,cn=users,c=uk passwordexpirydate=20100530130623z cn=jane,cn=users,c=uk passwordexpirydate=20100423140734z cn=michael,cn=users,c=uk passwordexpirydate=20100331020044z I want to end up with a file that looks like:-... (6 Replies)
Discussion started by: sniper57
6 Replies

6. Shell Programming and Scripting

Help w/ script to read file and parse log message

Hi, I am working on the script to parsing the specific message like "aaaa" in multiple log files like N1-***,N2-***,N3-***... The script is to find the list of lof files which contains the message "aaaa" and export the list into excel filE. Can anyone give help? Thanks (2 Replies)
Discussion started by: shyork2001
2 Replies

7. Emergency UNIX and Linux Support

Read file and change a 0 to a 1 in output

<key>ExcludeSimpleHostnames</key> <integer>0</integer> <key>FTPPassive</key> Need simple command that will change the 0 to a 1 in this file when I grep it, but only for this integer key directly after the ExcludeSimpleHostnames key. I got this output code... (8 Replies)
Discussion started by: glev2005
8 Replies

8. UNIX for Dummies Questions & Answers

Read from a file then filter the output

Hi i need a script which reads a certain file and then display it on the screen. The thing is i need to filter the display output. this is an example of the file which is to be loaded in the script. asdfg1.1.1|98 hjkldfe4.0.3|123 asdzxzvdweradfsdafascv10.0.10|123456789... (1 Reply)
Discussion started by: khestoi
1 Replies

9. Shell Programming and Scripting

Read popup message and save it in file

Hi, I am trying to automate one of the application using IE:Auotmation in perl My web application has few text fields and 2 buttons "Save Changes" and "Discard Changes".I have written code to enter values to the text fields fetching from input file and click the button "Save Changes".As soon as... (0 Replies)
Discussion started by: jyo123.jyothi
0 Replies

10. Shell Programming and Scripting

store output to a file and read from it

Hello all, I need to run snoop command for a period of time (a day) and extract remote host column from it to find out who is accessing my server. When I run the following on the command line it works snoop -port 22 | awk '{print $3}' but when I do snoop -port 22 | awk '{print $3}' | while... (2 Replies)
Discussion started by: afadaghi
2 Replies
Login or Register to Ask a Question