user input date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting user input date
# 8  
Old 03-18-2005
I think I confused you. When I do this inmy script:

echo "Date: \c"
read xxx

I am expecting a date input, i will take that and look in all my audit log files, and search for that date and search for a failed transaction, if they exist i will e-mail else exit. My log entry is like :

2005-02-10 16:56:55 SYCCSSSS006010I1 46626 Provisioning Transaction Succeeded

Gundu
# 9  
Old 03-18-2005
ok that makes things clears, though I assume if that a failure would look like:
2005-02-10 16:56:55 SYCCSSSS006010I1 46626 Provisioning Transaction Failed
if not update the bold part below.

Code:
# one email per logfile
#
# Assumes you have an array of log file names called FILES
#
echo "Date [YYYY-MM-DD] : \c"
read xxx

for file in ${FILES}; do
    grep "${xxx}.*Failed" ${file} > /dev/null 2>&1 || grep "${xxx}.*Failed" ${file} | uuencode ${file}_failedtransactions.txt | mailx -s "Failed Transactions for date ${xxx}" ${EMAIL}
done

Code:
# one email
#
# Assumes you have an array of log file names called FILES
#
echo "Date [YYYY-MM-DD] : \c"
read xxx

grep "${xxx}.*Failed" ${FILES} > /dev/null 2>&1 || grep "${xxx}.*Failed" ${FILES} | uuencode failedtransactions.txt | mailx -s "Failed Transactions for date ${xxx}" ${EMAIL}
done

# 10  
Old 03-21-2005
Thanks, but how can i do if i don't have an array:

echo "Date:[YYYY-MM-D] : \c"
read xxx

cd $HOME/audit
ls -ltr //list all the audit log files
cat * > file2 /opens all the audit log files and saves it in file2

I need to use the input date from above and check in this file is the date matched and also the key word like success or failed is there, if it is there then e-mail me else exit.

Thanks,
Gundu
# 11  
Old 03-21-2005
Code:
# one email per logfile
#
#
echo "Date [YYYY-MM-DD] : \c"
read xxx

for file in $HOME/audit/* ; do
    grep "${xxx}.*Failed" ${file} > /dev/null 2>&1 || grep "${xxx}.*Failed" ${file} | uuencode ${file}_failedtransactions.txt | mailx -s "Failed Transactions for date ${xxx}" ${EMAIL}
done

Code:
# one email
#
#
echo "Date [YYYY-MM-DD] : \c"
read xxx

grep "${xxx}.*Failed" $HOME/audit/* > /dev/null 2>&1 || grep "${xxx}.*Failed" $HOME/audit/* | uuencode failedtransactions.txt | mailx -s "Failed Transactions for date ${xxx}" ${EMAIL}
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

User input and run awk using the input

I am trying to allow a user to enter in text and then store that text in a variable $gene to run in an awk command in which those values are used to run some calculations. I am getting syntax errors however, when I try. Thank you :). The awk runs great if it is a pre-defined file that is used,... (7 Replies)
Discussion started by: cmccabe
7 Replies

2. Shell Programming and Scripting

Script to get previous date for the given input date..

hi all, need a script or command to get the previous date for the given input date... like in my script i will pass date as input parameter like 2014-12-01 and i want the output as previous date.. ie.. 2014-11-30 (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

3. Shell Programming and Scripting

Get yesterdays Date for Input Date

Hi, I have been trying to get the yesterdays date for the Input date I pass. I know how to do for the current timestamp but how to do for the input date. Is there any way I can convert to epoch time and do manipulations and back to human readable date? Please help Thanks ... (1 Reply)
Discussion started by: abhi1988sri
1 Replies

4. UNIX for Advanced & Expert Users

Help with ksh script to list, then cp files from a user input date range

Hi, I'm quite new to ksh scripting, can someone help me with this. Requirements: I need to create a script that list the files from a user input date range. e. g. format of file: *c1*log.2012-12-22-14-00* *c1*log.2012-12-22-14-00* *c1*log.2012-12-22-14-00*... (1 Reply)
Discussion started by: chococrunch6
1 Replies

5. Shell Programming and Scripting

Script interacts with user , based on user input it operates

i have a script which takes input from user, if user gives either Y/y then it should continue, else it should quit by displaying user cancelled. #!/bin/sh echo " Enter your choice to continue y/Y OR n/N to quit " read A if then echo " user requested to continue " ##some commands... (7 Replies)
Discussion started by: only4satish
7 Replies

6. Shell Programming and Scripting

display Range of date depend on user input php

Hi, i am very new to php Is it possible to display Range of date depend on user input day example: user input 2 day start from 28/4/12 it will add 2 day from date of input so display should look like this 28/4/12 to 30/4/12 then from 30/412 user add another 4 date so will... (0 Replies)
Discussion started by: guidely
0 Replies

7. Shell Programming and Scripting

How to get the user input recursively until the user provides valid input

Hi, echo "Enter file name of input file list along with absolute path : " read inputFileList if then for string in `cat inputFileList` do echo $string done else echo " file does not exist" fi From the above code, if the user enters a invalid file... (1 Reply)
Discussion started by: i.srini89
1 Replies

8. Shell Programming and Scripting

Search on date range of file based on user input

Hello I would like to ask for help with a script to search a directory that contains many log files and based on a users input after being prompted, they enter a date range down to the hour which searches the files that contain that range. I dont know how to go about this. I am hoping that the... (5 Replies)
Discussion started by: lostincashe
5 Replies

9. Shell Programming and Scripting

How to increment a user defined date value in the DATE format itself using shell script?

I need to increment a date value through shell script. Input value consist of start date and end date in DATE format of unix. For eg. I need increment a date value of 1/1/09 to 31/12/09 i.e for a whole yr. The output must look like 1/1/09 2/2/09 . . . 31/1/09 . . 1/2/09 . 28/2/09... (1 Reply)
Discussion started by: sunil087
1 Replies

10. Shell Programming and Scripting

Get date range between 2 date input

Hi Experts, I have files name report_20090416 report_20090417 report_20090418 report_20090420 report_20090421 I have 2 input from user From Date: 20090417 To Date: 20090420 and I need to grep only those line in between. Output should be report_20090417 report_20090418... (3 Replies)
Discussion started by: tanit
3 Replies
Login or Register to Ask a Question