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
Similar Messages
-
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? -
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? -
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()
-
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 -
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; -
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 -
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. -
Executing a UNIX shell script using SM49
I have been trying all sorts of things to get this to work and I have been un-successful
I am trying to run the UNIX script using SM49. the command line that I am using is
/test/directory/bin/testmail.sh
the script testmail.sh looks like
#!/bin/ksh
/usr/bin/mailx -s testmail <email address>
I have tried all sorts of combinations to run this script
example
sh /test/directory/bin/testmail.sh
/test/directory/bin/testmail.sh %f
/test/directory/bin/testmail.sh %F
does anyone have any suggestions on how to get this to run successfully. once I get this to run successfully in SM49, I am going to try it in the intregration builder of my PI process.Hi,
considering authorization issues, you can use
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
commandname = 'LIST_DB2DUMP'
additional_parameters = l_path
operatingsystem = 'UNIX'
TABLES
exec_protocol = lt_btcxpm
EXCEPTIONS
to extract information about files on the server
I used this code to get detailed information for display including the attributes
LOOP AT lt_btcxpm ASSIGNING <btcxpm>
WHERE length > 57
AND ( NOT message+57 CO '. '
OR message+57 = '..' )
AND ( message(1) = 'd' OR
message(1) = 'l' OR
message(1) = '-' ).
l_srvfil-type = <btcxpm>-message(1).
IF l_srvfil-type = '-'.
l_srvfil-type = 'F'.
ENDIF." l_srvfil-type = '-'.
TRANSLATE l_srvfil-type TO UPPER CASE. "#EC TRANSLANG
l_srvfil-file = <btcxpm>-message+57.
CONDENSE l_srvfil-file.
l_srvfil-attri = <btcxpm>-message+1(9).
* l_srvfil-time = <btcxpm>-message+44(12).
l_srvfil-size = <btcxpm>-message+32(11).
APPEND l_srvfil TO lt_srvfil.
ENDLOOP." at lt_BTCXPM assigning <BTCXPM>.
pt_srvfil = lt_srvfil.
For the srvfil information I used this structure
BEGIN OF typ_srvfil,
%_box TYPE flag, "#EC *
type TYPE char01,
attri TYPE isp_rel,
file TYPE file,
name TYPE file,
size TYPE sytleng,
owner TYPE sy-uname,
mod_date TYPE sydatum,
mod_time TYPE syuzeit,
END OF typ_srvfil,
I do not remember exactly how the attribute information is resolved. In Unix all file system authorizations can be set as for the user, the group or for all and it can be read, write, execute granted. If you are no unix expert, ask one or google/wiki for some details.
I wrote a program for navigation, display, and some more functions on the file system which is too big to post here and is not fully system-independent. Not perfect but useful and more than 5 years old. Contact me by mail if you want it.
Regards,
Clemens
Edited by: Clemens Li on Oct 23, 2009 9:16 PM -
Can i invoke Unix Shell Script using JSP or Java
Hi
I am working on developing web application .In this application user will upload a file and this file will be stored on server .once the file is saved i have to invoke shell script which triggers the informatica process to read the file content.
Can some please assist me on this. If any one have pseudo code for this it will be of great help
ThanksThis article has example code and explains how to use it.
You should read the entire article first.
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html -
Error while Executing Unix Shell Commands Using Runtime clas
I am trying to run the following code in java on unix machine to execute cat command.
Runtime runtime = Runtime.getRuntime();
try {
System.out.println("before catexecute");
Process process = runtime.exec("cat /export/home/shankerr/local.profile > /export/home/shankerr/local1.txt");
try {
if (process.waitFor() != 0) {
System.err.println("exit value = " +
process.exitValue());
catch (InterruptedException e) {
System.err.println(e);
But i get the following error on the console
exit value = 2
cat: cannot open >
cat: cannot open /export/home/shankerr/local1.txt
The same command if i run on unix console directly it creates a new file and copies the content into the new file local1.txt
kindly help me on the sameThe redirection operator > along with stuff like pipe | history !$ etc. is interpreted by the shell, not by the cat program.
When you do cat X > Ycat only sees the X. The rest is interpreted by the shell to redirect the cat program's stdout.
However, when you Runtime.exec(), you don't have the shell, so cat sees X > Y as its arguments, and interprets them all as file names. Since there's no file named > you get the error.
The solution is to first man cat on your system and see if it happens to have a -o or somesuch operator that lets it (rather than the shell) send its output to a file. If not, then you need to invoke a shell, and pass it cat and all of cat's args as the command to execute.
Read the man pages for you shell of choice, but for bash, I believe you'd give Runtime.exec() something like /bin/bash -c 'cat X > Y' -
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... -
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 -
Run shell script using Host Command
How do I run Unix Shell Script using Host command?
Please help me......Are you running the shell script from the same box as the forms are deployed in? If not, then HOST call will try to execute on the machine where the forms are hosted(App server).
Maybe you are looking for
-
Bought a mac mini and it's the wrong machine for my needs
HI all I bought the solid state drive mini mac - stupidly didn't realise that it had such low storage - then I made my biggest mistake - I left it in the box for 2 months over xmas as I wanted plenty of time to make the transition from my old mac pro
-
Can anyone help out in parsing the xml file.
i have this file as string in webdynpro. can anyone help out how can i parse it and attch to context of webdynpro with structure queryList Queryid name remarks <?xml version="1.0" encoding="UTF-8"?> <app-data> <content-data hyperlink="" name
-
What does error 45019 mean when installing itunes on Windows 8?
I am trying to install itunes on my Samsung Series 5 PC with Windows 8. I have installed QuickTime to get rid of the "no apple support component" error message, but now I get an error code -45019 that says a component of itunes is still missing afte
-
Question about subtotal in alv output
I am using REUSE_ALV_GRID_DISPLAY for my ALV output. In that i am sub-totaling for quantity base on material group(MATKL). But also I want to display material group descriptions(WGBEZ) at the same subtotal-line. How can do that?
-
Usb connection not working for itouch
I have a 1st generation iTouch and when connecting to my laptop via usb, it does not show in iTunes. Have worked through the online support steps and they did not remedy the issue. Even downloaded the lates version of iTunes.