Sponsored Content
Top Forums Shell Programming and Scripting Need help with a sh script to spool directory and modify the output (Oracle cnt file) Post 302328444 by exm on Wednesday 24th of June 2009 10:24:30 AM
Old 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

removing particular lines ending with a .cnt extension in a text file

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

To spool output from a database query

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

Help in Shell scripting to modify the User Creation script in oracle database.

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

Spool directory

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

Help supressing spool output from screen when calling sqlplus from script

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

SQL*PLUS Spool Output

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

Need a script for automatically cleaning up /var/spool/cups directory

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

UNIX spool command not extracting complete record from the Oracle table

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

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. $ cat test2.sh #!/bin/bash... (4 Replies)
Discussion started by: kraljic
4 Replies
grass-dbf(1grass)						Grass User's Manual						 grass-dbf(1grass)

NAME
grass-dbf - DBF driver DBF driver DBF driver in GRASS Defining the DBF driver The DBF driver is the default driver, in theory no user interaction is required. However, if the settings should be set back from a differ- ent to the DBF driver, the following step is required: # keep single quotes: db.connect driver=dbf database='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/' db.connect -p The dbf/ subdirectory in the mapset must exist or must be created by the user. Creating a DBF table Usually DBF tables are created by GRASS when generating a vector map with attributes (and using DBF as default attribute driver). If a DBF table has to be created manually, db.execute can be used or a spreadsheet application. Also db.copy is sometimes useful as well as db.in.ogr to import external tables. Supported SQL commands by DBF driver ALTER TABLE table ADD [COLUMN] columndef ALTER TABLE table DROP COLUMN colname CREATE TABLE table ( columndefs ) DROP TABLE table SELECT columns FROM table SELECT columns FROM table WHERE condition SELECT columns FROM table ORDER BY column DELETE FROM table DELETE FROM table WHERE condition INSERT INTO table VALUES (value1[,value2,...]) INSERT INTO table ( column1[,column2,...] ) VALUES (value1[,value2,...]) UPDATE table SET assignment1[,assignment2,...] UPDATE table SET assignment1[,assignment2,...] WHERE condition Operators available in conditions "=" : equal "<" : smaller than "<=" : smaller/equal than ">" : larger than ">=" : larger/equal than "<>" : not equal "~" : Substring matching (non-standard SQL) "%" : Substring matching (limited functionality) Arithmetic expressions using constants and field values are allowed in condition clauses and in the RHS of assignments. Usual precedence rules and bracketing (using '(' and ')') are supported. Type conversion is performed if necessary (experimental). Conditions allow boolean expressions using the AND, OR and NOT operators, with the usual precedence rules. NULLs can be tested by 'colname IS NULL' in conditions. The negation is 'colname NOT NULL'. Sorting: Empty fields in a character column are sorted to the end. LIMITATIONS OF THE DBF DRIVER
The DBF driver supports only a few SQL statements since the DBF tables are intended for simple table storage. DBF column names are limited to 10 characters (as defined in the DBF specifications). For example, aggregate functions (sum, count, min, max,...) are not supported in SELECT clauses; mathematic functions (sin, cos, exp, log,...) are not supported in expressions; SQL query with IN are not supported. ERROR MESSAGES
An error message such as: DBMI-DBF driver error: SQL parser error: syntax error, unexpected NAME processing 'IN'.. indicates that an unsupported SQL statement (here, 'IN') was used. The only solution is to switch the DBMI backend to a real SQL engine (SQLite, PostgreSQL, MySQL etc.). See SQL support in GRASS GIS. An error message such as: DBMI-DBF driver error: SQL parser error: syntax error, unexpected DESC, expecting NAME processing 'DESC' indicates that a column name corresponds to a reserved SQL word (here: 'DESC'). A different column name should be used. If this happens during import with v.in.ogr, the cnames parameter can be used to assign different column names on the fly. SEE ALSO
db.connect, SQL support in GRASS GIS DBF Specifications (Shapelib) Last changed: $Date: 2011-02-07 18:59:50 +0100 (Mon, 07 Feb 2011) $ Help Index GRASS 6.4.2 grass-dbf(1grass)
All times are GMT -4. The time now is 05:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy