06-24-2009
Need help with a sh script to spool directory and modify the output (Oracle cnt file)
Hi,
I'm creating a shell script to dynamically create a recreate controlfile for an Oracle database. I need to read a cold backup file system, and make some changes to these files.
Let's say for argument sake the directory name is /ebsprod_c/oradata and it looks like this:
/ebsprod_c/oradata/ctxd01.dbf
/ebsprod_c/oradata/discoverer01.dbf
/ebsprod_c/oradata/log01.dbf
/ebsprod_c/oradata/log02.dbf
/ebsprod_c/oradata/undo01.dbf
/ebsprod_c/oradata/undo02.dbf
/ebsprod_c/oradata/undo03.dbf
/ebsprod_c/oradata/undo04.dbf
/ebsprod_c/oradata/undo05.dbf
What I need is to:
a. exclude the log0* files
b. Add a apostrophe and a comma to each line, except the last line which should only have a apostrophe to make it look something like this:
'/ebsprod_c/oradata/ctxd01.dbf',
'/ebsprod_c/oradata/discoverer01.dbf',
'/ebsprod_c/oradata/undo01.dbf',
'/ebsprod_c/oradata/undo02.dbf',
'/ebsprod_c/oradata/undo03.dbf',
'/ebsprod_c/oradata/undo04.dbf',
'/ebsprod_c/oradata/undo05.dbf'
I figured out how to spool the files and add the apostrophe and comma:
for dirname in $(ls /ebsprod_c/oradata/*.dbf)
do
filename=$(echo $dirname)
echo "'$filename'," >> datafiles.tmp
done
But I can't figure out how to remove/exclude the comma from the last line and how to exclude the log0* files.
Any help would be appreciated!
Thanks!
Mark
9 More Discussions You Might Find Interesting
1. Solaris
I have a text file with rows of information (it is basically a ls command information(o/p from ls command))
I need to remove the lines ending with a .cnt extension and keep the lines ending with .zip extension, how to accomplish this.
I also only need the date,size and name of the file from every... (2 Replies)
Discussion started by: ramky79
2 Replies
2. Shell Programming and Scripting
Hi all,
I would want to spool file for a database query, however by using crontab, the file is not spooled. Below shows my script:
ORACLE_HOME="/u01/oraprod/perpdb/10.1.0/db_1"
OUTFILE="/tmp/invalid.out"
FILE="$HOME/admin/scripts"
$ORACLE_HOME/bin/sqlplus -s "/as sysdba"... (0 Replies)
Discussion started by: *Jess*
0 Replies
3. Shell Programming and Scripting
Hi,
I have several users to create on my test Oracle database taking the scripts from the Production Oracle database. I have a separate text file where I have user-id and passwords maintained. I need help in writing a shell script to go thru the user creation scripts and replace VALUES... (1 Reply)
Discussion started by: rparavastu
1 Replies
4. Solaris
hi all,
I have unix box
I install 2 zone on it
I want to make spool directory and assign one to each zone
How can I do that ? (5 Replies)
Discussion started by: coxmanchester
5 Replies
5. Shell Programming and Scripting
I'm calling an embedded sql from my shell script file. This sql does simple task of spooling out the contents of the table (see below my sample code) into a spool file that I specify. So far so good, but the problem is that the output is also displayed on screen which I do NOT want.
How can I... (3 Replies)
Discussion started by: MxC
3 Replies
6. Shell Programming and Scripting
Hi,
Im writing a script to run a bit of sql(via sqlplus) that pulls back some data and spools it to a file, I want the spool file to only display the data, with no sql command at the top and no reports at the bottom ie(# of records recieved).
I am currently doing it via a grep command but... (1 Reply)
Discussion started by: Magezy
1 Replies
7. Shell Programming and Scripting
Hi Friends,
Actually in an linux server , there was printer jobs files occupying more space in /var/spool/cups so i want a script for deleting the files once in two week since i need the latest two weeks files.
Thanks in advance..Waiting for the script. (2 Replies)
Discussion started by: Mohamed Thamim
2 Replies
8. UNIX and Linux Applications
Hello All,
I'm trying to spool an oracle table data into a csv file on unix server but the complete record is not being extracted. The record is almost 1000 characters but only 100 characters are being extracted and rest of the data getting truncated.
I'm setting below options :
SET... (4 Replies)
Discussion started by: venkat_reddy
4 Replies
9. Shell Programming and Scripting
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.
$ cat test2.sh
#!/bin/bash... (4 Replies)
Discussion started by: kraljic
4 Replies
LEARN ABOUT DEBIAN
dbf2mysql
DBF2MYSQL(1) General Commands Manual DBF2MYSQL(1)
NAME
dbf2mysql, mysql2dbf - convert between xBase and MySQL databases
SYNOPSIS
dbf2mysql [-v[v]] [-f] [-u|-l] [-n] [-o field[,field]] [-e conversion-file] [-s old-name=new-name[,old-name=new-name]] [-i field[,field]]
[-d database] [-t table] [-c[c]] [-p primary] [-h host] [-F] [-q] [-r] [-x] [-P password] [-U user] dbf-file
mysql2dbf [-v[v]] [-u|-l] -d database -t table [-h host] [-q query] [-P password] [-U user] dbf-file
DESCRIPTION
dbf2mysql takes an xBase file and sends queries to an MySQL server to insert it into an MySQL table.
mysql2dbf dumps a MySQL table to a dbf file.
OPTIONS
-v Produce some status output.
-vv More verbose.
-vvv Even more verbose: produce a progress report.
-f Translate all field names in the xBase file to lowercase.
-u Translate all text in the xBase file to uppercase.
-l Translate all text in the xBase file to lowercase.
-n Allow NULL fields: 'NOT NULL' will be not added in table creation statement.
-o field[,field[,...]]
List fields to insert into MySQL database. Primary use is to ease import of complex dbf files where we want only few fields. NOTE:
-o is processed before substitution (-s), so you have to use dbf field names here.
-e conversion-file
Specify file for CHAR fields conversion. File format is: 1st line: number of characters to convert (number of lines). Further
lines: <char_to_convert> <char_after_conversion>.
-s old-name=new-name[,old-name=new-name[,...]]
Takes a list of field name/new field name pairs. Primary use is to avoid conflicts between field names and MySQL reserved keywords.
When the new field name is empty, the field is skipped in both the CREATE clause and the INSERT clauses, i.e. it will not be present
in the MySQL table. For example:
-s ORDER=HORDER,REMARKS=,STAT1=STATUS1
-i field[,field[,...]]
List fields to be indexed. MySQL field names should be used here.
-d database
Select the database to insert into. Default is 'test'.
-t table
Select the table to insert into. Default is 'test'.
-c[c] Create table if one doesn't exist already. If the table already exists, drop it and build a new one. The default is to insert all
data into the named table. If -cc is specified, no records will be inserted.
-p primary
Select the primary key. You have to give the exact field name.
-h host
Select the host to insert into. Untested.
-F Fixed length records. (By default CHAR is saved as VARCHAR.)
-q dbf2mysql: "Quick" mode. Inserts data via temporary file using 'LOAD DATA INFILE' MySQL statement. This increased insertion speed
on my PC 2-2.5 times. Also note that during whole 'LOAD DATA' affected table is locked.
mysql2dbf: Specify custom query to use.
-r Trim trailing and leading whitespace from CHAR type fields data.
-x Start each table with _rec and _timestamp fields.
-P password
Specify password on the MySQL server.
-U user
Specify user on the MySQL server.
BUGS
mysql2dbf can't write MEMO files at this time.
Possibly incorrect field lengths for REAL numbers.
AUTHORS
Originally written by Maarten Boekhold <boekhold@cindy.et.tudelft.nl>, Oct 1995.
Patched for MySQL by Michael Widenius <monty@analytikerna.se>, 3 Nov 1996.
Manual page written for Debian GNU/Linux from README by Heiko Schlittermann <heiko@lotte.sax.de>, Aug 1997; updated by Matej Vela
<vela@debian.org>, Nov 2001.
COPYRIGHT
Use this piece of software as you want, modify it to suit your needs, but please leave my name in place ok? :)
DISCLAIMER
The authors do not accept any responsibility for possible damage you get as result of using this program.
Debian Project 2001-11-18 DBF2MYSQL(1)