Executing Unix shell scripts with DBMS_SCHEDULER
I have the following Unix shell script create_backup_file.sh:
#!/usr/bin/ksh
/usr/bin/ssh [email protected] /usr/bin/touch/app_home/home/trotestbat/scripts/TRO_batch_complete_`date +%d-%m-%Y-%H%M`
If I execute this from the command prompt it creates the file on the remote server.
I've used dbms_scheduler to try and execute this from Oracle:
BEGIN
SYS.DBMS_SCHEDULER.CREATE_PROGRAM
program_name => 'CREATE_TRO_BACKUP_FILE'
,program_type => 'EXECUTABLE'
,program_action => '/APP/TORPEDO/DTE/SCRIPTS/create_backup_file_tro.sh'
,number_of_arguments => 0
,enabled => TRUE
,comments => NULL
SYS.DBMS_SCHEDULER.CREATE_JOB
job_name => 'DTE.TESTAGAIN'
,start_date => TO_TIMESTAMP_TZ('2010/05/17 16:09:24.710789 +01:00','yyyy/mm/dd
hh24:mi:ss.ff tzh:tzm')
,repeat_interval => NULL
,end_date => NULL
,program_name => 'DTE.CREATE_TRO_BACKUP_FILE'
,comments => NULL
END;
The problem I have is that scheduler executes the shell script and creates the file but it never completes the job. The status of the job is permanently 'RUNNING'. Why is the scheduler not returning a completed status?
the "infinite" script is usually caused by a prompt (script pauses for a user input).
Please keep in mind that executing script via scheduler is not the same as manually via prompt.
1. the script runs as ORACLE user ID (or whatever you specified using DBMS_SCHEDULER.create_credential or/and "$ORACLE_HOME/rdbms/admin/externaljob.ora")
2. the environment variables are probably not the same.
My wild guess is that you never ran SSH using "oracle" UID and thus it prompts for permission to add the remote computer’s fingerprint to the user’s ~/.ssh/known_hosts file - since it is a script, it just hangs and waits for input.
Did you try to login to unix box as oracle uid and run the script manually?
Similar Messages
-
Executing a shell script with DBMS_SCHEDULER
Hi,
when I execute a shell script with DBMS_SCHEDULER this doesn't works correctly
BEGIN
DBMS_SCHEDULER.create_job
job_name => 'job_AR',
job_type => 'EXECUTABLE',
job_action => '/home/crm/crmdw/AR/start_execution.sh',
enabled => TRUE,
start_date => systimestamp,
repeat_interval => 'FREQ=MINUTELY;INTERVAL=15',
comments => 'Test Job AR'
END;Inside the shell script there is a code who call a Hierarchy of process,
if I executed it manually or with a cron, it works perfectly
but when I execute it with the job that I've described before it's executes
all process at same time and it doesn't work.
What can I do to fix the issue,
any Ideas?
Thanks in advanced...#!/usr/bin/ksh
#test_dbms_scheduler.ksh
echo $1
echo "I am in Unix"
exit 0
chmod 755 test_dbms_scheduler.ksh
Create or replace procedure test_dbms_scheduler
as
v_text varchar2(255) := 'Parameter passed from Oracle to Unix';
Begin
dbms_output.put_line("I am in Procedure");
dbms_scheduler.create_job
(job_name=>'test_dbms_scheduler',
job_action=>'/usr/bin/test_dbms_scheduler.ksh',
number_of_arguments=>1,
job_type=>'executable',
start_date => SYSDATE,
repeat_interval => 'FREQ=SECONDLY; INTERVAL=1',
enabled=>false,
auto_drop => TRUE,
comments=> 'Run shell-script test_dbms_scheduler.ksh');
dbms_scheduler.set_job_argument_value(job_name =>'test_dbms_scheduler', argument_position => 1, argument_value => v_text);
dbms_scheduler.enable('test_dbms_scheduler');
dbms_output.put_line("I am back in Procedure");
Exception
when others then
dbms_output.put_line(sqlcode||sqlerrm);
end;
set serveroutput on
exec test_dbms_scheduler; -
Execute unix shell script using DBMS_SCHEDULER
Hi,
I am trying run to shell script using DBMS_SCHEDULER.
1) I check..nobody user exist on my HP-UX.
2) I check externaljob.ora on (10.2.0.2.0) also..It has an entry..
run_user = nobody
run_group = nobody
3) I created job successfully and enabled it.
begin
DBMS_SCHEDULER.CREATE_JOB
job_name => 'test_unix_script',
job_type => 'EXECUTABLE',
job_action => '/tmp/test.ksh',
start_date => '08-NOV-2006 04:45:16 PM',
job_class => 'DEFAULT_JOB_CLASS',
enabled => TRUE,
auto_drop => FALSE,
comments => 'test_unix_script.'
END;
EXEC DBMS_SCHEDULER.enable('test_unix_script');
4) test.ksh script had -r-xr-xr-x permission.
5) When I checking dba_scheduler_job_run_details view, ADDITIONAL_INFO column display following error messgae.
ORA-27369: job of type EXECUTABLE failed with exit code: No such file or directory
Did I miss anything?
Any help will be appreciated!!
Thanks..My /tmp/test.ksh trying to find database status.
. ~oracle/.profile > /dev/null
db_status=`eval sqlplus -s 'system/passwd@DEV' << EOF
set pagesize 0 feedback off verify off heading off echo off
select status from v\\$instance;
exit
EOF`
echo $db_status > /tmp/db_status_out -
How to execute unix shell script in webdynpro?
hi all,
We have some iquirement of executing script in unix.If anyone know How to execute unix shell script in webdynpro?
best regard
reefishRee,
1. Find SSH client for windows, then execute SSH with Runtime.exec() on local host with arguments like remote host, auth, command to execute etc.
2. Get SSH client in Java and execute SSH commands on remote host using pure Java API.
Don't ask me for links, Google works today, I checked this
Valery Silaev
SaM Solutions
http://www.sam-solutions.net -
Error while executing unix shell script from java program
Hi All,
I am trying to execute unix shell script from a java program using Runtime.execute() method by passing script name and additional arguments.
Code snippet :
Java Class :
try{
String fileName ="test.ksh";
String argValue ="satish"; // value passed to the script
String exeParam = "/usr/bin/ksh "+fileName+" "+argValue;
Process proc = Runtime.getRuntime().exec(exeParam);
int exitValue = proc.waitFor();
sop("Exit Value is : "+exitValue);
catch(Exception e)
e.printStackTrace();
}Test.ksh
export -- application realated paths..
nohup abc.exe 1> test.log 2>&1;
$1
exit.By running the above java class , i am getting exit Value: 139 and log file test.log of 0 bytes.
when i am running the same command (/usr/bin/ksh test.ksh satish) manually, it's calling abc.exe file successfully
and able generate the logs properly.
Pls let us know where exactly i am stuck..
Thanks in advance,
Regards,
SatishHi Sabre,
As per the guidelines provided by the article, i had done below changes..
InputStream is = null;
InputStreamReader iStreamReader = null;
BufferedReader bReader = null;
String line = null;
try{
String fileName ="test.ksh";
String argValue ="satish"; // value passed to the script
String exeParam = "/usr/bin/ksh "+fileName+" "+argValue;
Process proc = Runtime.getRuntime().exec(exeParam);
is = proc.getErrorStream();
iStreamReader = new InputStreamReader(is);
bReader = new BufferedReader(iStreamReader);
System.out.println("<ERROR>");
while((line = bReader.readLine()) != null)
System.out.println("Error is : "+line);
System.out.println("</ERROR>");
int exitValue = proc.waitFor();
sop("Exit Value is : "+exitValue);
catch(Exception e)
e.printStackTrace();
Now , it's showing something like..
<ERROR>
</ERROR> -
How to execute unix shell script from Java ...
Hi,
Anyone know how to execute unix shell script from Java?
Suppose I have several shell scripts written in perl or tcl or bash.
I just want to catch the output of that script.
Is there any ready to use module/object for this?
Please let me know, this is quite urgent for my study assigment.
Thanks in advance,
Regards,
meLook up Runtime.exec()
-
RFC_REMOTE_PIPE is Returning 1 alwasys and not able to execute Unix shell script
Hello All,
I am trying to execute a simple unix shell script from ABAP.
What I did so far..
1. created a test.sh file with single command echo "Hello".
2. placed this file on application server /Usr/sap/test.sh
3. executing ABAP program which as FM RFC_REMOTE_PIPE
CODE:
CALL FUNCTION 'RFC_REMOTE_PIPE'
DESTINATION 'SERVER_EXEC'
EXPORTING
command = lv_command
read = 'X'
TABLES
pipedate = lt_stdout
EXCEPTIONS
system_failure = 1
communication_failure = 2.
if i populate lv_command = echo "hello" it works fine
if i give .sh file path in lv_command it is not working. it returns 1.
Please help...
I was searching SDN i found that rfcexec service should be enabled... how do i check that..
i checked t code \SMGW , i don't see any output...
i checked FM GWY_READ_CONNECTED_SYSTEMS, i don't hsee anyting related to unix...
Please suggest.I resolved the issue.
It was issue with permission.
Script file should have full permission ( Mode 777)..
Thanks everyone. -
Unix Shell Scripts with Oracle
Any body who can give me the link where I can find the Unix Shell Scripts to access the Oracle database and execute the stored procedures and cursors.
Your unix script will contain (at appropriate places):
sqlplus -s username/pasword@server @your_sql_Script_that_calls_the procedure.SQLor
sqlplus -s / @your_sql_Script_that_calls_the procedure.SQL -
Telneting to a remote host and executing unix shell script
I am using VPN.I want to telnet to a remote server and execute some script there and show it the output in my front end..is it easily possible thru java..i know it can be easily done thru Python...can anyone let me knw if this can ve achieved properly thru java..thnx plz let me knw ASAP.
Yes surely I have wriiten the code..
I have first used a Socket to connect to teh host at port 23.
Then i am using outstream to give the user and passwd .. but in my Inputstream i am getting some vague outputs (some symbols..$,%,etc..) This is the code for ur reference....
import java.net.*;
import java.io.*;
class Telclient {
public static void main(String args[]) {
int c;
try{
Socket s=new Socket("abc.net",23);
InputStream in=s.getInputStream();
OutputStream out=out.getoutputStream();
String str="user" + "\n" + "password" + "\n";
byte buf[]=str.getBytes();
out.write(buf);
while((c=in.read()) != -1) {
System.out.println((char)c);
s.close();
Please help with teh code , bcoz its not really working..Need urgent helpI also used TelnetClient from jakarta , but failing to understand
how to use those classes to use..can anyone show me an example... -
Issue with calling Shell Script using DBMS_SCHEDULER
Hi All,
I am executing a shell script using DBMS_SCHEDULER from APEX web page. Execution part is working fine without any issues.
In my shell script file (abc.sh) I have few oracle sql procedure calls which connects back to same database and that SQL call is not executing some reason, it not giving any errors.
Inside my shell script code looks like this.
sqlplus -silent $USER/$PASSCODE@$SCONNECT > /dev/null <<END
set pagesize 0 feedback off verify off heading off serveroutput on
echo off linesize 1000
WHENEVER SQLERROR EXIT 9
BEGIN
dbms_output.enable(1000000);
do_enable_cons();
dbms_output.disable;
END;
spool off;
exit;
END
When I run this shell script file from backend it works fine now issues.
Is there any restrictions in executing sql code using DBMS_SCHEDULER? Any ones help is much appreciated.
-Regardsjames. wrote:
Thanks you sb and Sybrand . It is problem with environment variables. After running .bash_profile in the beginning of the shell script, it is working fine.
One issue is when I check the process it is showing two entries with two different process id's.
The command I used
ps -ef | grep <my script> is COPY & PASTE broken for you?
any reason why you did not show us EXACTLY was produced by OS command above?
>
Is it something wrong with my code or is it normal? Is it really executing two times ?
-Regards
bcm@bcm-laptop:~$ sqlplus user1/user1
SQL*Plus: Release 11.2.0.1.0 Production on Fri Jul 20 15:14:15 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
15:14:15 SQL> !ps -ef | grep sqlplus
bcm 24577 1903 1 15:14 pts/0 00:00:00 sqlplus
bcm 24579 24577 0 15:14 pts/0 00:00:00 /bin/bash -c ps -ef | grep sqlplus
bcm 24581 24579 0 15:14 pts/0 00:00:00 grep sqlplus
15:14:23 SQL> how many different copies of "sqlplus" running on my laptop based upon actual output above? -
Call Unix Shell Script From OBIEE
Hi All,
Is it possible to do a call to a Unix Shell Script with the Action Framework from OBIEE.
Thanks in AdvanceI dont think so but we can go for it instead of BI side. Try to port the same functionality on shell script side, so that the script can identify your report using tail of nqquery log and execute the rest of your lines in shell script.
This can doable and works as expected. If at all you are going with my suggestion you can go for a small key word to identify your report instead of that lengthy logical query.
Pls mark if helps -
Hi all,
Can any body tell me
1) How to get file creation time and
2) whether the file exists or not in UNIX shell scripts
Regards,
PavaniHi Pavani,
Go through this blog, and as mentioned use "Add Time Stamp" to get the file creation time.
/people/sameer.shadab/blog/2005/09/21/executing-unix-shell-script-using-operating-system-command-in-xi
Regards,
Sarvesh -
Error executing shell script using dbms_scheduler
I have a job running which executes a shell script,which fails with following error :
SQL> SELECT additional_info
2 FROM user_scheduler_job_run_details
3 WHERE log_date = (SELECT MAX (log_date)
4 FROM user_scheduler_job_run_details);
ADDITIONAL_INFO
ORA-27369: job of type EXECUTABLE failed with exit code: No such file or directory
STANDARD_ERROR="mkdir: Failed to make directory "/export/home/bwsolaris/abc"; Permission denied"
This are contents of my shell script
#!/bin/ksh
/bin/mkdir /export/home/bwsolaris/abc
Can anyone suggest me some way out of it?
Thanks in advance!!!Does oracle still creates a user nobody"nobody" is a "standard" Unix/Linux lowly privileged user, which is used by DBMS_SCHEDULER by default.
You should change permissions on /export/home/bwsolaris, e.g.
$ chmod 777 /export/home/bwsolaris
or use a different directory, where everyone has access, for example /tmp.
Or take a look at Metalink Note:391820.1 - Scheduled Job Running Shell Script Fails With ORA-27369 -
Error while trying to execute a unix shell script from java program
Hi
I have written a program to execute a unix shell script in a remote machine. I am using J2ssh libraries to estabilish the session connection with the remote box.The program is successfully able to connect and authenticate with the box.
The runtime .exec() is been implemented to execute the shell script.I have given below the code snippet.
try {
File file_location = new File("/usr/bin/");
String file_location1 = "/opt/app/Hyperion/scripts/daily";
String a_mib_name = "test.sh";
String cmd[] = new String[] {"/usr/bin/bash", file_location1, a_mib_name};
Runtime rtime = Runtime.getRuntime();
Process p = rtime.exec(cmd, null, file_location);
System.out.println( "Connected to the server1" );
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = br.readLine();
while(line !=null)
System.out.println(line);
line = br.readLine();
br.close();
p.getErrorStream ().close ();
p.getOutputStream().close();
int retVal = p.waitFor();
System.out.println("wait " + retVal);
//session.executeCommand("ls");
catch (IOException ex) {
I get an error message
Connected to the server
java.io.IOException: Cannot run program "/usr/bin/bash" (in directory "\usr\bin"
): CreateProcess error=3, The system cannot find the path specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at SftpConnect.main(SftpConnect.java:143)
Caused by: java.io.IOException: CreateProcess error=3, The system cannot find th
e path specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
I am sure of the file path where the bash.sh and test.sh are located.
Am i missing something? Any help would be greatly appreciated.
Thanks
SenthilHi, I am using a simple program to connect to a RMI server and execute shell script. I use the Runtime.exec aommand to do the same.
The script is sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul
The script when run from the server, gives no errors. But when ran using rthe above method in java, gives errors as follows,
Mycode:
String command = "/bin/sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul";
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(command);
int exitVal = proc.exitValue();
System.out.println("Process exitValue: " + exitVal);
java.io.IOException: CreateProcess: /bin/sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul error=3
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at DecryptTest.main(DecryptTest.java:18)
Can anyone please help -
Unix shell script should execute (run) webI report.
Hi
i am new to BO.
I have webI reports developed, can any one tell me how to execute a webI reprot using unix sheel script.Hello Vijaya,
Thatu2019s an interesting question. BusinessObjects does not supply any native UNIX shell interfaces or scripts for running/executing Webi Reports. Not knowing what it is you are exactly trying to accomplish Iu2019ll give a very general answer.
I have had several customers who had requirements to have external systems execute, refresh and export reports in BusinessObjects Enterprise before. These external systems could execute a shell script so what they have ended up doing is creating generic Java applications that use the BusinessObjects BOE Java SDK. Once they had the Java application created their external application could execute a java directory or they created shell wrappers that were called. So what you could do is create some Java applications that wrap the functionally you need and then execute those from the command line.
With that said there is a lot of functionally built into BusinessObjects Enterprise. If I was to know exactly what you were trying to achieve I might be able to point you in the direction of an existing product feature.
Cheers,
David.
Maybe you are looking for
-
How can I call an ".asp" from a Servlet?
I want to make a call to an asp page from my servlet. If i use the conventional way of doing it as follows: RequestDispatcher rd = getServletContext().getRequestDispatcher("http://localhost:8080/abc.asp"); rd.forward(request, response) It gives me Il
-
hi everyone, i've updated all software etc to ios 5.0.1 from ios 4.1 as it has taken me 1 year to figure out how do the update. Everything has been restored and working but i've been able to connect to my wi-fi but still won't let me use the internet
-
Oracle EBS 11.5.10.2 not working in IE 9 on Windows 7 64-Bit
Hi, I upgraded our Oracle EBS(11.5.10) to 11.5.10.2+DB 11g R2+Sun JRE. Some users having IE 9 on Windows 7 (64-Bit) are not able to access the Forms based products, though this combination is mentioned in Note: 290807.1. Please let me know if any wor
-
Changing "Check Shopping Cart" screen and Completion workflow
Hi, Below i describe a) the current process, b) the required changes, and c) my questions. Though it is also about workflows i still thought this was the best place to post the thread. Current process: In the process "free text order" i choose Go Sho
-
InfoView ignores CR 10 tab stops!
To all: I have a report in Crystal 10 in which I set tab stops within a text box to creat text in a tabular format. I have headings and data fields on the next line, at the same tab stops. When I populate the report within Crystal, the mini-table app