Sponsored Content
Top Forums Shell Programming and Scripting Extracting Sysdate-1 ORA Errors - Can you help me in this UNIX Script? Post 302794755 by hanson44 on Tuesday 16th of April 2013 03:28:26 PM
Old 04-16-2013
I could not make the awk syntax work. The problem I ran into was using an awk command line variable inside a RE. Here was the closest I got:
Code:
$ cat log
Thu Apr 15 01:34:25 2013
Line 1 for April 15
Thu Apr 15 02:00:00 2013
Line 2 for April 15
Thu Apr 16 19:15:03 2013
Line 1 for April 16
Thu Apr 16 19:15:06 2013
Line 2 for April 16
Thu Apr 17 19:21:16 2013
Line 1 for April 17
Thu Apr 17 19:40:28 2013
Line 2 for April 17

Code:
a=`date '+%b %d' -d "yesterday"`
b=`date '+%b %d'`
awk '/$y/,/$t/ {print}' y="$a" t="$b" log

Maybe some other expert can provide an awk solution.

-----------------------------------------------

Here is a way to do this using sed:
Code:
a=`date '+%b %d' -d "yesterday"`
b=`date '+%b %d'`
echo a = $a, b = $b
sed -n "/$a/,/$b/ p" log | sed '$d'

Code:
$ ./temp.sh
a = Apr 15, b = Apr 16
Thu Apr 15 01:34:25 2013
Line 1 for April 15
Thu Apr 15 02:00:00 2013
Line 2 for April 15

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Getting sysdate - 2 by an unix command

How can I get an equivalent in unix for the following Oracle SQL command: select sysdate - 2 from dual; Thanks José (4 Replies)
Discussion started by: josecollantes
4 Replies

2. UNIX for Dummies Questions & Answers

sysdate -1 in unix

I need to automate the creation of a file. It needs to have the date of the previous day. In sqlplus we use sysdate -1 but I checked the man page for date and didn't find a similar command. This is what I use for creating a file for the current date: rciind`date '+%m%d%Y'`.txt What do I... (1 Reply)
Discussion started by: kskywr
1 Replies

3. Shell Programming and Scripting

Unix shell script (grep -A 6 -B 2 "ORA-" filename

BACKGROUND: I am using Solaris 10. Some of my boxes have gnu grep and I can use -A and -B flags on those. However, the solaris flavor of grep won't use the flags -A or -B. And some of my boxes won't be getting gnu grep. Should I try using perl, awk, or sed? Actual PROBLEM: I am... (7 Replies)
Discussion started by: el_guero
7 Replies

4. Shell Programming and Scripting

How to get ORA errors in alertlog file using shell script.

Hi, Can anyone tell me how to get all ORA errors between two particular times in an alertlog file using shell script. Thanks (3 Replies)
Discussion started by: suman_dba1
3 Replies

5. Solaris

maxuprc and maxusers - ORA-27300, ORA-27301, ORA-27302

Hi all, Am intermittently getting the following errors on one of my databases. Errors in file /oracle/HRD/saptrace/background/hrd_psp0_13943.trc: ORA-27300: OS system dependent operation:fork failed with status: 12 ORA-27301: OS failure message: Not enough space ORA-27302:... (1 Reply)
Discussion started by: newbie_01
1 Replies

6. UNIX for Advanced & Expert Users

grep all ORA errors except one ORA error

Hi - I am trying to grep all "ORA" errors in a log files.I have to grep all ORA errors except one error for example ORA-01653.How can exclude that error in "grep" command? In following "grep" command I want to exclude "ORA-01653" error grep -i ORA alert.log >>/tmp/ora_errors.txt ... (7 Replies)
Discussion started by: Mansoor8810
7 Replies

7. Shell Programming and Scripting

Shell script to capture ORA errors from Alert Log

Hi, as the title says, I am after a simple script, which will open the Alert log from an 11.2.0.1 Linux environment and mail the error message and description to a recipient email address. I can then schedule this job via cron and let it run every 15 minutes. I have searched online... (16 Replies)
Discussion started by: jnrpeardba
16 Replies

8. Shell Programming and Scripting

How to turn off ora errors in shell script?

I have a shell script which select total count from a table and use its value in a if condition like below connect_string="username/password@tnsname" tot=`sqlplus -s $connect_string << EOF set echo off set feedback off set head off select count(*) from test_table; EOF ` if then echo... (2 Replies)
Discussion started by: vel4ever
2 Replies

9. Shell Programming and Scripting

Shell script to capture Current day ORA errors from Alert Log

Please provide Shell script to capture ORA errors from Alert Log for a given date or Current date. -Veera (1 Reply)
Discussion started by: Veera_V
1 Replies

10. Shell Programming and Scripting

Check for “errors” or “ORA-”

I want to check for "errors" or "ORA-" in Y.if there is an error then exit Y=`sqlplus -s user/passwd<< EOF exec test_Proc; exit; EOF` if ; then exit 1 fi but this doesnt work (6 Replies)
Discussion started by: haadiya
6 Replies
OCI_PASSWORD_CHANGE(3)													    OCI_PASSWORD_CHANGE(3)

oci_password_change - Changes password of Oracle's user

SYNOPSIS
bool oci_password_change (resource $connection, string $username, string $old_password, string $new_password) DESCRIPTION
resource oci_password_change (string $dbname, string $username, string $old_password, string $new_password) Changes password for user with $username. The oci_password_change(3) function is most useful for PHP command-line scripts, or when non-persistent connections are used throughout the PHP application. PARAMETERS
o $connection - An Oracle connection identifier, returned by oci_connect(3) or oci_pconnect(3). o $username - The Oracle user name. o $old_password - The old password. o $new_password - The new password to be set. o $dbname - The database name. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 oci_password_change(3) example changing the password of an already connected user <?php $dbase = 'localhost/orcl'; $user = 'cj'; $current_pw = 'welcome'; $new_pw = 'geelong'; $c = oci_pconnect($user, $current_pw, $dbase); oci_password_change($c, $user, $current_pw, $new_pw); echo "New password is : " . $new_pw . " "; ?> Example #2 oci_password_change(3) example of connecting and changing the password in one step <?php $dbase = 'localhost/orcl'; $user = 'cj'; $current_pw = 'welcome'; $new_pw = 'geelong'; $c = oci_pconnect($user, $current_pw, $dbase); if (!$c) { $m = oci_error(); if ($m['code'] == 28001) { // "ORA-28001: the password has expired" // Login and reset password at the same time $c = oci_password_change($dbase, $user, $current_pw, $new_pw); if ($c) { echo "New password is : " . $new_pw . " "; } } } if (!$c) { // The original error wasn't 28001, or the password change failed $m = oci_error(); trigger_error('Could not connect to database: '. $m['message'], E_USER_ERROR); } // Use the connection $c ?> NOTES
Note Changing the password either with this function or directly in Oracle should be done carefully. This is because PHP applications may continue to successfully reuse persistent connections by authenticating with the old password. The best practice is to restart all web servers whenever the user password is changed. Note If upgrading the Oracle client libraries or the database from a release prior to 11.2.0.3 to version 11.2.0.3 or higher, oci_pass- word_change(3) may give the error "ORA-1017: invalid username/password" unless both client and server versions are upgraded at the same time. Note The second oci_password_change(3) syntax is available since OCI8 version 1.1. Note In PHP versions before 5.0.0 you must use ocipasswordchange(3) instead. This name still can be used, it was left as alias of oci_password_change(3) for downwards compatability. This, however, is deprecated and not recommended. PHP Documentation Group OCI_PASSWORD_CHANGE(3)
All times are GMT -4. The time now is 10:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy