Shell script for calling an sql file
Hello, I would need your help in creating a ksh file. We have two ksh files. One for deletion the eim table and the other one is for running the eim job.
Ksh file for running the eim job is okay. But the ksh file running the delete sql is not. We were thinking that we may have some sort of mistake in the syntax could have caused the problem we experiencing now. Need your expertise to check it. Please?
Here’s the syntax we have.
#!/bin/sh
sqlplus -s <user>/<pwd>@dbname << EOF
@<folder-path>/sqlrun.sql
EXIT
ENDSQL
EXIT
When we run it against putty, nothing seems to happen as in no error message appears at all. It prove that the sql file did not execute in TOAD.
We tried the other way around, by putting the /dev/nu// as show below.
sqlplus -s <user>/<password>@DBNAME > /dev/null <<ENDOFSQL
still nothing happen.
Regards
user10070712 wrote:
Hello, I would need your help in creating a ksh file. We have two ksh files. One for deletion the eim table and the other one is for running the eim job.
Ksh file for running the eim job is okay. But the ksh file running the delete sql is not. We were thinking that we may have some sort of mistake in the syntax could have caused the problem we experiencing now. Need your expertise to check it. Please?What does this have to do with APEX, which is the topic of this forum?
What is "eim"? Why have you chosen to post this here?
Similar Messages
-
Shell script for below pl/sql script dbms_file_transfer
Please let me know how tt write the shell script for below pl/sql script dbms_file_transfer it is
I have trasfer the files from asm into filesystem .
it is working . but i have to put in the loop
begin
dbms_file_transfer.copy_file(
source_directory_object => 'src',
source_file_name => 'ncsn',
destination_directory_object => 'dest',
destination_file_name => 'ncsn');
end;
Edited by: user8680248 on 27/10/2009 20:55user8680248 wrote:
Please let me know how tt write the shell script for below pl/sql script dbms_file_transfer it is
I have trasfer the files from asm into filesystem .
it is working . but i have to put in the loop
begin
dbms_file_transfer.copy_file(
source_directory_object => 'src',
source_file_name => 'ncsn',
destination_directory_object => 'dest',
destination_file_name => 'ncsn');
end;What database version?
What are you trying to do exactly?
It's working but you have to put it in a loop. Fine, what's the problem you are having?
begin
loop
exit when ... whatever the exit condition is ...
dbms_file_transfer.copy_file(
source_directory_object => 'src',
source_file_name => 'ncsn',
destination_directory_object => 'dest',
destination_file_name => 'ncsn');
end loop;
end; -
Shell script for moving and renaming files
I'm not so familiar with shell scripts. I have created some simple scripts for various tasks but now I hit something I can't handle myself.
My server receives every night a logfile from another server. This file I need to rename and move to another location. Problem is that a simple mv with new filename isn't enough, I need to insert date in filename. Format for date should be ddmmyy. Also the name of incoming file changes every night. The output always starts with same letters, let's say "log", and the date is used to identify files.
For example I receive a file /Input/filename.log and I need to move the file to the folder /Output with name log130308.txt.
Any tips how to insert the date as part of of filename while renaming or moving the file? I prefer shell script as I'll use launchd for scheduling the script.Hi again,
so far I've constructed this:
cd /input
for file in `ls *log`
do
echo "Copying " $file
cp $file /output/log.$file.`date +%d%m%y`
done
Quite there. I'm cding to directory, i'll focus later how to set some environmental parameters.
Problem with zipping is that I don't know exact logfiles names. Each day there's a new name. So zip -q filename.zip filename.log isn't quite enough and it's impossible to use wildcards. The switch -q and checksums were welcome suggestions.
Thanks again,
Juha
Message was edited by: J.Otava -
Shell script for oracle alert.log file
Hi Gurus,
I wanted to write shell script to know the last 10 shutdown timings of the database from alert log file. I'm working on oracle 9i.
Could anyone please advice on this.
Thanks in advance
regards,
Shaan
Edited by: Shaan_dmp on Jan 5, 2009 1:27 PM
Edited by: Shaan_dmp on Jan 5, 2009 1:28 PMUse awk. I don't have a 9i to hand but here is a very simple version for 10g XE
My awk file (the line numbers are for the notes below - don't include them:
01:BEGIN { prevline = "";}
02:
03:/Completed: alter database close/ {print prevline,FS,$0;}
04:
05:{prevline = $0;}The command line and results (from my 300k alert log)
$ awk -f alert.awk.txt alert_xe.log
Fri Apr 11 18:08:40 2008 Completed: alter database close normal
Fri May 16 18:53:21 2008 Completed: alter database close normal
Tue May 20 17:28:23 2008 Completed: alter database close normal
Thu Jul 17 19:08:52 2008 Completed: alter database close normal
Fri Aug 15 15:12:48 2008 Completed: alter database close normal
Wed Nov 05 08:52:59 2008 Completed: alter database close normal
Fri Nov 14 16:36:03 2008 Completed: alter database close normal
Tue Dec 09 10:46:23 2008 Completed: alter database close normal
Mon Jan 05 11:12:22 2009 Completed: alter database close normalWhat it means:
1) the BEGIN section at line 01 defines the variable to hold the previous line
2) the /search string/ at line 03 finds the marker in the file for a shutdown, then does the required action (print the time which was in the previous line, and then this line; use FS (the awk field separator - normally space) as a separator
3) at line 05 is an instruction we do on every line - so we remember it in case it is the timestamp for the shutdown.
Now, you can include more of the corner cases for shutdowns by adding more search patterns etc. For more information, google for awk examples.
Awk is really good at this sort of thing!
HTH
Regards Nigel -
How to call shell script from a pl/sql procedure
Hi all,
I am little bit new to plsql programming, i have a small problem as follows
I have to call a shell script from a pl/sql procedure ..
Please suggest me some methods in oracle 10g, which i could make use of to achieve my goal. also please tell me what are the constraints for those methods if any.
I already came across dbms_scheduler, but i have got a problem and its nor executing properly its exiting giving 255 error or saying that permission problem, but i have already given full access to my shell scripts.
Thanks in advance
Best Regards
SatyaHi,
Read this thread, perhaps is there your response :
Host...
Nicolas. -
Shell script to call sql script
Hi All,
I have a application server and want to make a shell script to call sql script.
Please let me know how to do the same.
Regards
KumarWhat is the platform you are using and you can give the path of the sql script in your shell script as follows
1.)first create .sql file...let it is table.sql and has the contents ...
create table test(x1 varchar2(20),x2 number(4),x3 date)
exit;
(2.) write a shell script...like table.sh in vi editor
Here login is scott/tiger@sid, or apps/apps@sid or whatever you know valid schema
echo enter the login
read login
sqlplus -s $login @table
(3.)run the script
$ sh table.sh
it will create the table in your particular schema -
Shell scripting for sql queires
Hi All,
I have written 4 sql queires.now i want to write shell scripting for this.so please guide me in this issue..
1. select * from emp;
2. select * from dept;
3. delete from emp;
4. delete from dept;
Thank you.Hi,
Apologees for the c!=k!=b stuff. I guess it was to cryptic. It means
C shell is not equal to Korne shell and both are not equal to Bourne shell.
I can't provide you with any site for such stuff. Maybe Google might help? Or someone who is a nicer guy than me... -
Pls give some shell scripting for sql/plsql
pls give some shell scripting for sql/plsql
794244 wrote:
pls give some shell scripting for sql/plsqlNeither SQL or PL/SQL are shell script languages. Both are server side languages that executes inside an Oracle database server process.
This is an important concept to understand when using SQL*Plus for example to "script" interaction with an Oracle database. -
Need Shell Script for picking the files
Hi,
I want to write a shell script for piking the files in a sequence order (according to filename with time stamp) from the sorce FTP server ..
Requirement is in the source directory I'm getting files (Jain_1.xml , Jjain_2.xml, Jain_3.xml .. ect..) at present my file adapter is picking all the files at a time but i want to pick one by one... that to first i want to Jain_1.xml after finish the processing of the file then only my file adapter should pick the next file ( Jain_2.xml ) .
so.. all the forum mates suggest me to write a shell script.. but where i have to write the s hell script. and where i have to deploy this script.... my Xi is running on UNIX ... so please sugest me the procedure ...
Regards
JainHi,
Why dont you use the option EOIO in which files will be picked up in order and will be proccessed in sequence....one after another....
Regards,
Sreeni. -
Hi,
I have written shell script for below scenarios, can you please guide me to write this as correct way, requirment is,
1. i need to connect the database which is on unix server , but before connecting the DB some of the files needs to be removed from \tmp directory.
2. once removed the script need to connect the database and call the sql file which is in \tmp directory.
3. the output files will be stored in \tmp directory start with DB name.
4. finally csv files needs to be transferred to local windows with help of FTP. please find below the script
#!/bin/sh
rm -f /tmp/dbmon/DB1*
CONNSTRING=username/PASSWORD@service
sqlplus -s $CONNSTRING @/tmp/STATS.sql << EOF
EXIT;
EOF
HOST='xxxxx'
USER='xxxxx'
PASSWD='xxxxxx'
FILE='E:\STATS\DB1.*'
cd /tmp/dbmon
ftp -n -v $HOST << EOT
user $USER $PASSWD
prompt
mput $FILE
bye
EOT
EXIT;
EOF
Thanks
Edited by: ASP on Nov 18, 2011 4:45 PMHi ASP
It's always a good idea to write entries to timestamped log file without which you will never know where the script went wrong or failed.
This is not tested but just a small example
#!/bin/sh
export LOG_DIR=/tmp/log
export LOGFILE=$LOG_DIR/`basename $0`_${TIMESTAMP}.log
if [ ! -d $LOG_DIR ]
then
mkdir $LOG_DIR
fi
echo "Removing the temporary files from /tmp/dbmon at `date +%Y%m%d_%H:%M:%S`" | tee -a $LOG_FILE
rm -f /tmp/dbmon/DB1*
CONNSTRING=username/PASSWORD@service
echo "Run SQLPlus file" | tee -a $LOG_FILE
sqlplus -s $CONNSTRING @/tmp/STATS.sql << EOF
EXIT;
EOF
echo "Now FTP the files to windows box " | tee -a $LOG_FILE
HOST='xxxxx'
USER='xxxxx'
PASSWD='xxxxxx'
cd /tmp/dbmon
ftp -vn $HOST <<EOF
quote USER $USER
quote PASS $PASSWD
ascii
cd E:\STATS
mput DB1.*
bye
EOF -
Shell Script not getting invoked in File adapter
Hi all,
Requirement:
PI need to pick the file from source directory and send it to target directory using SFTP.
I'm using SCP command for this purpose.
When I run the shell script (with simple SCP command) from command prompt, script is working fine.
Same script is called from PI File adapter but script is not getting invoked.
In the communication channel logs, "Executed OS command" is available. There are no Error/Warning messages in the log.
NFS transport protocol is used in the File communication channel.
Complete directory path of the shell script is mentioned in File channel -> Run Operating System command after message processing.
Even the following simple command is not working from PI receiver file channel:
echo "Test file" >> /data/test.txt
Please let me know if I'm missing out something.
Thanks,
GeethaHi Geetha,
I think the syntax u are using is not correct. Please follow the below syntax:
/path/<script_name> %F
for ex: /staging/Interface/XI/Script/FTPData %F
use the above in the communication channel.
%F should be after a space.
FTPData is the script name
/staging/Interface/XI/Script/ is the location where the script is present
Cheers,
Souvik
Edited by: Souvik Chatterjee on Apr 14, 2011 3:38 PM -
Shell script for batch compilation of forms 10g on AIX 5.3L AS
Hi All,
Can anybody provide me the Shell script for batch compilation of forms 10g and reports 10g on AIX 5.3L AS?
Regards,
SAMHi Alex,
I tried with the below script as well as the one you had posted.
ORACLE_HOME=/opt/oracle/OraHome_3
export ORACLE_HOME
TNS_ADMIN=$ORACLE_HOME/network/admin
export TNS_ADMIN
LIBPATH=$ORACLE_HOME/lib32:$ORACLE_HOME/jdk/jre/bin:$ORACLE_HOME/jdk/jre/bin/cla
ssic:$LIBPATH
export LIBPATH
cd ../forms
for i in `ls *.pll`
do
echo Compiling Library $i ....
$ORACLE_HOME/bin/frmcmp module=$i userid=mydbuser/mydbuser@mydb
batch=yes module_type=library
compile_all=yes window_state=minimize
done
export ORACLE_HOME=/opt/oracle/OraHome_3
export ORACLE_TERM=vt220
export LD_LIBRARY_PATH=/opt/oracle/OraHome_3/lib:/opt/oracle/OraHome_3/jdk/jre/l
ib:/opt/oracle/OraHome_3/jdk/jre/lib/i386:
cd ../forms
for i in `ls *.pll`
do
echo "Compiling Library $i ...."
/opt/oracle/OraHome_3/bin/frmcmp module_type=form userid=mydbuser/mydbuser@mydb
module=$i batch=yes compile_all=no
window_state=minimize upgrade=no
done
echo "PLL Compilation done"
But there was a same kind of error thst turning up all the time.
Compiling Library Agf.pll ....
Forms 10.1 (Form Compiler) Version 10.1.2.0.2 (Production)
Forms 10.1 (Form Compiler): Release - Production
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
PL/SQL Version 10.1.0.4.2 (Production)
Oracle Procedure Builder V10.1.2.0.2 - Production
Oracle Virtual Graphics System Version 10.1.2.0.0 (Production)
Oracle Multimedia Version 10.1.2.0.2 (Production)
Oracle Tools Integration Version 10.1.2.0.2 (Production)
Oracle Tools Common Area Version 10.1.2.0.2
Oracle CORE 10.1.0.4.0 Production
FRM-10043: Cannot open file.
Form not created
I hence updated the permissions on the pll as below
-rwxrwxrwx 1 oracle oinstall 335872 May 19 16:31 Agf.pll
But the problem is still persisting.
My environment details are as below.
I am working on Win XP machine. Connected to my AS via telnet and xmanager. I have set my DISPLAY to my local IP.
Is there any thing more that I need to do? If so then let me know.
Regards,
SAM -
Shell Script for Startup and Shutdown the database
Hi,
i want Shell Script for Startup and Shutdown the database in Solaries.
could any one can hep me where i can get this script. or send to me to [email protected]
Thanks & Regards,
Gangi reddySHUTDOWN
SHUTDOWN ABORT]
Shuts down a currently running Oracle instance, optionally closing and dismounting a database.
Terms
Refer to the following list for a description of each term or clause:
ABORT
Proceeds with the fastest possible shutdown of the database without waiting for calls to complete or users to disconnect.
Uncommitted transactions are not rolled back. Client SQL statements currently being processed are terminated. All users currently connected to the database are implicitly disconnected and the next database startup will require instance recovery.
You must use this option if a background process terminates abnormally.
IMMEDIATE
Does not wait for current calls to complete or users to disconnect from the database.
Further connects are prohibited. The database is closed and dismounted. The instance is shutdown and no instance recovery is required on the next database startup.
NORMAL
NORMAL is the default option which waits for users to disconnect from the database.
Further connects are prohibited. The database is closed and dismounted. The instance is shutdown and no instance recovery is required on the next database startup.
TRANSACTIONAL [LOCAL]
Performs a planned shutdown of an instance while allowing active transactions to complete first. It prevents clients from losing work without requiring all users to log off.
No client can start a new transaction on this instance. Attempting to start a new transaction results in disconnection. After completion of all transactions, any client still connected to the instance is disconnected. Now the instance shuts down just as it would if a SHUTDOWN IMMEDIATE statement was submitted. The next startup of the database will not require any instance recovery procedures.
The LOCAL mode specifies a transactional shutdown on the local instance only, so that it only waits on local transactions to complete, not all transactions. This is useful, for example, for scheduled outage maintenance.
Usage
SHUTDOWN with no arguments is equivalent to SHUTDOWN NORMAL.
You must be connected to a database as SYSOPER, or SYSDBA. You cannot connect via a multi-threaded server. For more information about connecting to a database, see the CONNECT command earlier in this chapter.
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a90842/ch13.htm#1013607
Joel Pérez -
Do I run a shell script (bsh) via PL/SQL stored procedure?
Hello guys,
Do I run a shell script (bsh) via PL/SQL stored procedure?
For example:
procedure X is
(variables)
begin
-- Read file data
vFileHandle := utl_file.fopen('/mnt/novell/', 'file.txt','r');
exception
when 'INVALID READ FILE' then
(I've to try running script to mount a Novell partition.);
end;
I've to installed Oracle 9.0.1 on Suse Linux.
Please, any ideas or hints ...
Thx and regards.You might be able to us the HOST command, I think you'd have to run it via dbms_sql, check this page for more details, not sure if it'll be of help but its worth a try..
http://otn.oracle.com/docs/products/oracle8i/doc_library/817_doc/server.817/a82950/ch8.htm
Cheers
Rob -
About shell scripts for large-scale automation of encoding tasks
in the user menu of Compressor, it said that we can use the command line to write shell scripts for large-scale automation of encoding tasks.
I would like to have more information about the shell script for compressor, is that any document link?
ThanksYou can use a script function to set-up a more secure environment that you call at the start of every admin script. This could be your main stamp album for stuff that can be moved there.
A few more stamps to add to the collection (be sure to read up on them before use):
1) reset the command hash
hash -r
2) prevent core dumps
ulimit -H -c0
3) set the IFS
4) clear all aliases (see unalias -a)
Also you can remove the ALL from sudo and add explicit commands to the the sudoers file. There's a lot of fine tuning you can do in sudoers - inc. env variables as teekay said.
But I'm no expert so best to check all of the above.
Maybe you are looking for
-
How to retrieve old purchases with the same Apple ID but from a different country
I used to be on the US app store and purchased apps, music and books on it. Now I have changed it to a South African account but can't update apps or download my old apps onto new devices. Any advice would be appreciated. Thanks
-
Different Business Area in Customer line item while Billing
Dear Friends, We are on Ecc 6.0 and We have a requirement of Different Business Area in Customer line while billing. Since we had defined Business area location wise and requirement is Sundry Debtors should always book to Location as maintained in de
-
if i was going to buy the Apple care for my iPod touch which one would i buy cause there is an iPod one and an iPhone one and the iPod touch is like both of them so anyone help please?!
-
Logon_time in v$session gives old date for new session
Hi, I have a unique issue whenever I run v$session for username='A' and status= active I see logon_time as old date in this its '12-MAY-2008'. Now there are total 150 sessions for username='A'. 2 are status= Active, 1 is status=Killed and 147 are sta
-
Managing Users Across Numerous Servers
Hey all, got a question. I have 6 servers that my company uses to host all of the media we use on a daily basis. We're tightening security around here, so I'm setting them up to allow each of our 80 users to admin their own passwords. Seems simple, y