Sponsored Content
Top Forums Shell Programming and Scripting Append date to sql*plus spool (log) file in shell script Post 302994964 by kraljic on Thursday 30th of March 2017 06:54:58 AM
Old 03-30-2017
Append date to sql*plus spool (log) file in shell script

SQL*Plus version : 11.2.0.4
OS : Oracle Linux 6.5

SQL*Plus is a client application to connect to oracle database. The log file for this tool is generated via spool command as shown below.

I am trying to append date ( $dateString ) to spool file as shown below.

Code:
$ cat test2.sh
#!/bin/bash

dateString=`date +%d-%b-%Y_%H%M%S`

sqlplus scott/tiger@10.82.16.214:1521/ORCL<<EOF

set time on timing on

spool /home/appusr/scripts/'$dateString'_batch.log

select sysdate from dual;

spool off

EOF
exit

But the log file generated has single quote around the date part as shown below. How can I get rid of this ?

Code:
$ ls -l
total 8
-rw-rw-r-- 1 appusr appusr 360 Mar 30 18:35 '30-Mar-2017_183552'_batch.log
-rwxr-xr-x 1 appusr appusr 224 Mar 30 18:35 test2.sh

I tried escaping the single quotes using \ character. But, still the same issue.

Code:
spool /home/appusr/scripts/\'$dateString\'_batch.log

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need a script to Append date to generated .txt file

Hi, Can anyone plz share their experience with - Building shell script to append the file with date in following format- Filename_MMDDYYYY.txt Thanks in advance (2 Replies)
Discussion started by: prince_of_focus
2 Replies

2. UNIX for Advanced & Expert Users

Shell script to append a time for the existing error log file

Hi Guys, the requirement is like this, i am having a error log file in this format, 4594.493: parallel nursery GC 2594592K->2544691K (2969600K), 30.848 ms 4605.958: parallel nursery GC 2634887K->2584986K (2969600K), 38.900 ms 4619.079: parallel nursery GC 2822555K->2774812K... (12 Replies)
Discussion started by: gsprasanna
12 Replies

3. Shell Programming and Scripting

PL SQL Runtimes different in Shell script log

Hi, This run times recorded in UX shell script appears peculiar to me. The PL / SQL stored procedure is called through sqlplus from UNIX shell script and then a log is created with run times recorded. The first set has actually taken 6 Hrs but the recorded time indicates it is only 2 Hrs and... (1 Reply)
Discussion started by: Nanu_Manju
1 Replies

4. Shell Programming and Scripting

shell script to read a line in gps receiver log file and append that line to new file

Hi, I have gps receiver log..its giving readings .like below Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GPSD,R=1 $GPGSV,3,1,11,08,16,328,40,11,36,127,00,28,33,283,39,20,11,165,00*71... (3 Replies)
Discussion started by: gudivada213
3 Replies

5. Shell Programming and Scripting

Convertion of Date Format using SQL query in a shell script

When I write Select date_field from TableA fetch first row only I am getting the output as 09/25/2009. I want to get the output in the below format 2009-09-25 i.e., MM-DD-YYYY. Please help (7 Replies)
Discussion started by: dinesh1985
7 Replies

6. Shell Programming and Scripting

Passing filename dynamically in SPOOL of SQL*PLUS in shell script

Hi all, I am executing shell script in which I am using SQLLDR In this SQLLDR I am passing text file having PL/SQL script. This script will produce some formated output, this output I have to spool in another text file. Currently I have given this in script file as following Spool... (2 Replies)
Discussion started by: shekharjchandra
2 Replies

7. Programming

create a spool file based on values passed from korn shell to sql script

this is my issue. 4 parameters are passed from korn shell to sql script. parameter_1= varchar2 datatype or no value entered my user. parameter_2= number datatype or no value entered my user. parameter_3= number datatype or no value entered my user. parameter_4= number datatype or no... (5 Replies)
Discussion started by: megha2525
5 Replies

8. Shell Programming and Scripting

Delete log files content older than 30 days and append the lastest date log file date

To delete log files content older than 30 days and append the lastest date log file date in the respective logs I want to write a shell script that deletes all log files content older than 30 days and append the lastest log file date in the respective logs This is my script cd... (2 Replies)
Discussion started by: sreekumarhari
2 Replies

9. Shell Programming and Scripting

Spool - Append and Calculation

I am running a cron job, every 6 hours a day (6 AM, 12 PM, 6 PM, and 12 AM), #!/usr/bin/ksh ...... $SQLPLUS / as sysdba <<! @/home/oracle/scripts/daily.sql ! cat /home/oracle/scripts/dbsizedaily.lst | mail -s "$TODAY: PROD DB Size" $RECIPIENTS "@/home/oracle/scripts/daily.sql" has ... (7 Replies)
Discussion started by: Daniel Gate
7 Replies

10. Shell Programming and Scripting

Shell Script | Parse log file after a given date and time stamp

I am developing one script which will take log file name, output file name, date, hour and minute as an argument and based on these inputs, the script will scan and capture all the error(s) that have been triggered from a given time. Example: script should capture all the error after 13:50 on Jan... (2 Replies)
Discussion started by: ROMA3
2 Replies
SQL::Translator::Schema::Procedure(3pm) 		User Contributed Perl Documentation		   SQL::Translator::Schema::Procedure(3pm)

NAME
SQL::Translator::Schema::Procedure - SQL::Translator procedure object SYNOPSIS
use SQL::Translator::Schema::Procedure; my $procedure = SQL::Translator::Schema::Procedure->new( name => 'foo', sql => 'CREATE PROC foo AS SELECT * FROM bar', parameters => 'foo,bar', owner => 'nomar', comments => 'blah blah blah', schema => $schema, ); DESCRIPTION
"SQL::Translator::Schema::Procedure" is a class for dealing with stored procedures (and possibly other pieces of nameable SQL code?). METHODS
new Object constructor. my $schema = SQL::Translator::Schema::Procedure->new; parameters Gets and set the parameters of the stored procedure. $procedure->parameters('id'); $procedure->parameters('id', 'name'); $procedure->parameters( 'id, name' ); $procedure->parameters( [ 'id', 'name' ] ); $procedure->parameters( qw[ id name ] ); my @parameters = $procedure->parameters; name Get or set the procedure's name. $procedure->name('foo'); my $name = $procedure->name; sql Get or set the procedure's SQL. $procedure->sql('select * from foo'); my $sql = $procedure->sql; order Get or set the order of the procedure. $procedure->order( 3 ); my $order = $procedure->order; owner Get or set the owner of the procedure. $procedure->owner('nomar'); my $sql = $procedure->owner; comments Get or set the comments on a procedure. $procedure->comments('foo'); $procedure->comments('bar'); print join( ', ', $procedure->comments ); # prints "foo, bar" schema Get or set the procedures's schema object. $procedure->schema( $schema ); my $schema = $procedure->schema; equals Determines if this procedure is the same as another my $isIdentical = $procedure1->equals( $procedure2 ); AUTHORS
Ken Youens-Clark <kclark@cshl.org>, Paul Harrington <Paul-Harrington@deshaw.com>. perl v5.14.2 2012-01-18 SQL::Translator::Schema::Procedure(3pm)
All times are GMT -4. The time now is 08:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy