Calling shell script from apex application
Please let me know if anyone has tried Calling shell script from apex application, it would be nice enough if you can share how you did it? Thanks
Hi,
Requirements
* CREATE JOB (10g Rel.1)
* CREATE EXTERNAL JOB (10g Rel.2 / 11g)
* EXECUTE on dbms_scheduler (granted to public by default)
Since Oracle 10.2.0.2 the commands are executed as user nobody.
Code:
--Create a Program for dbms_scheduler
exec DBMS_SCHEDULER.create_program('RDS2008','EXECUTABLE','c:\ WINDOWS\system32\cmd.exe /c echo 0wned >> c:\rds3.txt',0,TRUE);
--Create, execute and delete a Job for dbms_scheduler
exec DBMS_SCHEDULER.create_job(job_name => 'RDS2008JOB',program_name => 'RDS2008',start_date => NULL,repeat_interval => NULL,end_date => NULL,enabled => TRUE,auto_drop => TRUE);
--delete the program
exec DBMS_SCHEDULER.drop_program(PROGRAM_NAME => 'RDS2008');
--Purge the logfile for dbms_scheduler
exec DBMS_SCHEDULER.PURGE_LOG;
This is one way as suggested by Trent.
We can also achieve as follows.
http://www.dba-oracle.com/t_execute_shell_script_plsql_procedure.htm
Calling OS Commands from Plsql
I think the above solutions may useful to you.
Let me know if you are facing any problem.
Thanks and Regards
Maheswara
Similar Messages
-
Calling ASP script from APEX button passing Bind variable
I am looking for some examples or best form for calling asp script from apex button that will pass apex bind variable to asp script to process.
Thanks,s
BobI am surprised by the degree of no replies. I have solved this by using asp redirects such as:
Response.Redirect("test.aspx?UserName="&user)
My formulated solution contains a page with a manually built interactive report. I have a number of bind variables at the top of the reoprt where users can query the information they want based on desginated database columns for this particular report. Once they have the "manual" interactive report displaying what they want, they click a button where a asp script is called with parameters passed that calls a Java based Crystal Reports plugin with the called correspnding report displayed with passed parameters.
Works like a charm!
This solves our reporting needs without having to resort to Bi Publisher (much too expensive) and other third party applications that kinda indicate it can work with apex but provide limited help or best form for doing so.
Bob -
Can we call shell script from oracle 9i?
Hi experts,
I wanted to know can we call shell script from oracle 9i procedures? If yes,how
Thanks
ShaanNo. I can't think of a way to do this...
If you want you can use DBMS_SCHEDULER to call OS SHELL scripts within.
For e.g.
CREATE PROGRAM
begin
dbms_scheduler.create_program
program_name => 'CHECK_TIME',
program_type => 'EXECUTABLE',
program_action => '/opt/oracle/chk_date.sh',
enabled => TRUE,
comments => 'Check the Time'
end;
CREATE A SHELL SCRIPT
opt/oracle> cat chk_date.sh
#!/usr/bin/ksh
echo "The date is :`date`"
CREATE SCHEDULE
begin
dbms_scheduler.create_schedule
schedule_name => 'EVERY_30_MINS',
repeat_interval => 'FREQ=MINUTELY; INTERVAL=30',
comments => 'Every 30-mins'
end;
CREATE JOB
begin
dbms_scheduler.create_job
job_name => 'RUN_CHECK_TIME',
program_name => 'CHECK_TIME',
schedule_name => 'EVERY_30_MINS',
comments => 'Run the program CHECK_TIME every 30 minutes',
enabled => TRUE
end;
MANUALLY RUN A JOB
exec dbms_scheduler.run_job('RUN_CHECK_TIME'); -
Calling linux / unix shell scripts from APEX
Hi -- I'm doing some prototyping, and would like to try calling a unix shell script on the server from within APEX.
Is this possible? Maybe thru Javascript? Other ways? Not sure if it's possible thru pl/sql.
FYI, I'm attempting to check username/password specified at login to see if it's a valid login
to another database (also specified at login). If there's an easier way to do this, I'd love to hear it!
We're highly motivated to have a single apex app work on multiple databases -- largely because of a lack of
administration resources on the other databases. All databases are accessible via database links from
the apex server (the links are necessary to implement other business rules), and I know I can get
the DML working. Powers that be prefer that Database Account authentication (or a facsimile thereof)
be used. I suspect I'm opening myself up to lots of criticism by disclosing this ... :)
Thanks for any ideas,
CarolR -- If I understand you correctly, a pl/sql process in APEX could invoke a java program on the server. Is that correct?
If so, is there any reason it couldn't just call a unix shell script? Seems they're both just executables recognized by the OS....
I know I called unix scripts from embedded sql a billion years ago, but don't recall the method for doing that. What is
the syntax I'd use in apex / pl/sql?
thanks,
Carol -
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. -
Calling shell script from sql procedure
Hi gurus
Is it possible
1)to call a shell script from sql procedure
2)that shell script has to return one value
3)and again sql procedure(calling shell script) has to capture the return value.
please help me to write this scriptYou may NOT have EXECUTE privilege/ permissions on the DBMS_PIPE package. Check with your DBA.
Using DBMS_PIPE may not be that simple to implement. Just making a call to DBMS_PIPE procedure will not do anything. It will NOT trigger anything on the UNIX side.
. You will also need to :
1. Write a job (ie CRON) at UNIX side which will keep read the incoming pipe for new messages, Unpack the message and get the command to be executed at the UNIX side -- There will be a lot of work involved here + DBA presence/activity is also required.
As Justin has pointed out, try and use HOST command which is very simple or try and use Java.
Shailender Mehta -
Calling Shell Script From Java
Hi i have a shell script which calls the ant command.How do i call this shell script from jdk 1.5. I used p = runtime.exec( filename) but it threw an IOException saying cannot execute. How do i call this from my java program which runs on the redhat linux box.Please Help
Possibility:
It does not have execute permissions - Either grant them by chmod or use the command as sh <script-name>
Rich -
11g - calling shell script from trigger
From what I read so far, starting from 11g onward user credential IS REQUIRED in order to call the shell script from database procedure/trigger. I am working in a shop where they used SSO (so no password) and having a local user with password is not possible.
I wonder if anyone used any other method to call the shell scripts from database procedure/trigger?
Thanks alluser550338 wrote:
performance is not going to be a problem for this requirement b/c it ONLY happened after the startup or before the shutdown.
That still -- even more so --- sounds like a bad idea. Exactly what does this shell script accomplish that needs to be triggered by database startup/shutdown? -
Calling shell script from stored procedure.
Hi Everybody,
Could anyone tell me how to call a shell script from a stored procedure.
Thanks,
VasuYou would need to write a Java stored procedure that calls out to the underlying operating system. Tom Kyte has an example of this here
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:952229840241
Make sure that you're very aware of the security implications here, however. Your commands will run as the Oracle user on the host operating system, which makes it possible that a coding error and/or an attacker could do something like delete or corrupt Oracle data files, so you'll probably want to harden the code substantially.
Justin -
Hello All,
I have been using some well known Java Class and Procedures to execute shell scripts from PL-SQL.
The different environments I was using before were
1)
Operating System (Server) AIX version 5
Oerating System(Client) Microsoft Windows XP Service Pack 2
Oracle Database Version Oracle Database 10g Enterprise Edition Release
10.2.0.1.0
2)
Operating System (Server) Red Hat Linux 3.4.5-2
Oerating System(Client) Microsoft Windows XP Service Pack 2
Oracle Database Version Oracle Database 10g Enterprise Edition Release
10.2.0.1.0
But suddenly I had to drop and recreate the Databases on 1st (AIX) environment
and
reinstall the Operating System (Server) Red Hat 3.4.5-2 on IInd environment stated above (which obviously means the reinstallation of Oracle Database there!)
Now the shell script(through PL-SQL)is executing smoothly for the IInd (Linux) environment[b] but not executing for the Ist (AIX) environment
and I am not getting how to solve the problem.
I have given all the permissions to users, shell scripts and all as they were before.
Can you please help?
Regards,
Abhijit.Hello All,
I have been using some well known Java Class and Procedures to execute shell scripts from PL-SQL.
The different environments I was using before were
1)
Operating System (Server) AIX version 5
Oerating System(Client) Microsoft Windows XP Service Pack 2
Oracle Database Version Oracle Database 10g Enterprise Edition Release
10.2.0.1.0
2)
Operating System (Server) Red Hat Linux 3.4.5-2
Oerating System(Client) Microsoft Windows XP Service Pack 2
Oracle Database Version Oracle Database 10g Enterprise Edition Release
10.2.0.1.0
But suddenly I had to drop and recreate the Databases on 1st (AIX) environment
and
reinstall the Operating System (Server) Red Hat 3.4.5-2 on IInd environment stated above (which obviously means the reinstallation of Oracle Database there!)
Now the shell script(through PL-SQL)is executing smoothly for the IInd (Linux) environment[b] but not executing for the Ist (AIX) environment
and I am not getting how to solve the problem.
I have given all the permissions to users, shell scripts and all as they were before.
Can you please help?
Regards,
Abhijit. -
Calling shell script from forms9i
Hi,
I have a shell script that inserts records in the table. When I run this shell script in Unix, it runs fine and inserts records in the table.
But when I run it from forms9i by using HOST command it does everything written in the shell script but inserting records in the table.
Can anyone tell me why it is not inserting records in the table.
I will really appreciate you response.
Thanks,
KumarIMO when you run the shell script from forms it runs in privileges of App server user and in that shell that why its running as oraias when you run it from forms .. I think the SSO is out of picture in this situation.So you need to find a way of connecting to the in the script.
Check the TNS names environment varaibles etc for doing this, -
Calling shell scripts from within Oracle PL/SQL codes
Hello,
We are migrating from informix to Oracle. In our Informix Stored Procedure we
were able to call Unix Shell Script by executing a 'SYSTEM' command, such as:
CREATE PROCEDURE magazine(flag1, flag2)
SYSTEM '/pics2/informix/mag.sh' || flag1 || flag2;
END PROCEDURE;
How can I write this in PL/SQL? Is there a simillar command for 'SYSTEM' in PL/SQL?
ThanksMike,
Wrong forum, for this question, suggest you ask it in the PL/SQL forum.
Jim Stern -
Calling Shell Script from BPEL
I hav a requirement of calling a shell script (.sh) from BPEL. Can anybody help me out....how can i achieve this?
For embedding Java:
http://download.oracle.com/docs/cd/B31017_01/integrate.1013/b28981/java.htm#sthref1282
For Java:
http://forum.java.sun.com/thread.jspa?threadID=635568&messageID=3700440
try
String execString = "ls -all"
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(execString);
/* handle you process from here..
outputstreams, inputStreams and such
catch (Exception e)
e.printStackTrace()
} -
Executing a unix kill from APEX or running a bash shell script from Apex
I'm writing a browser based app that I would like to write with APEX and that will identify and kill a very specific process name and Unix user name combo.
I can identify the unix PID in V$SESSION if I want so, I know how to to the first part (identify the process/PID).
How can an APEX app execute the Linux kill command? I'm not seeing anyway to host out of APEX. I was looking for something like that where you create processes...
Please provide only suggestions on how to do this from APEX. I know there are lots of other ways (CGI from Apache etc.).I have this working, though it's kinda clunky.
Apex calls Oracle Stored Procedure which calls Java stored procedure which defines a class that runs exec to execute an OS command, and waits for the return value.
The DBA had to grant special permission for my oracle schema to execute the script name that is passed into the Java.
Others may have a better way of doing this. -
Calling shell script from udev rule
Hello,
I've encrypted partition with key stored on usb drive. I created udev rule:
SYSFS{size}=="....", SYSFS{serial}=="....", ACTION=="add", SYMLINK+="pendrive", RUN=="/bin/sh /home/kamil/bin/cryptsetup.sh"
as You can see I would like to call cryptsetup.sh when pendrive has been inserted. This script looks like:
/bin/mount /media/pendrive
/usr/sbin/cryptsetup luksOpen /dev/sda7 enc1 -d /media/pendrive/key.txt
/bin/mount /mnt/enc1
The idea is to create /dev/mapper/enc1 and mount it automatically without any user action. My problem is that second line of this script (cryptsetup command) hangs for a long time - minute or two.
Here, if it helps, is the listing of processess when cryptsetup hangs:
ps ax | grep crypt
1379 ? S< 0:00 [kcryptd/0]
6418 ? S< 0:00 [kcryptd/1]
8046 ? S< 0:00 /usr/bin/perl /home/kamil/bin/cryptsetup.sh
8049 ? S<L 0:01 /usr/sbin/cryptsetup luksOpen /dev/sda8 enc2 -d /media/pendrive/key.txt
8098 pts/2 S+ 0:00 grep crypt
Notice status of command /usr/bin/cryptsetup... - it's S<L. I don't know if it is connected to the problem.
When I comment out this udev rule, connect the pendrive and than manually call cryptsetup.sh I have no problem and everything works fine.
Any ideas how to fix that?
Thanks, best regards
KamilHi,
Requirements
* CREATE JOB (10g Rel.1)
* CREATE EXTERNAL JOB (10g Rel.2 / 11g)
* EXECUTE on dbms_scheduler (granted to public by default)
Since Oracle 10.2.0.2 the commands are executed as user nobody.
Code:
--Create a Program for dbms_scheduler
exec DBMS_SCHEDULER.create_program('RDS2008','EXECUTABLE','c:\ WINDOWS\system32\cmd.exe /c echo 0wned >> c:\rds3.txt',0,TRUE);
--Create, execute and delete a Job for dbms_scheduler
exec DBMS_SCHEDULER.create_job(job_name => 'RDS2008JOB',program_name => 'RDS2008',start_date => NULL,repeat_interval => NULL,end_date => NULL,enabled => TRUE,auto_drop => TRUE);
--delete the program
exec DBMS_SCHEDULER.drop_program(PROGRAM_NAME => 'RDS2008');
--Purge the logfile for dbms_scheduler
exec DBMS_SCHEDULER.PURGE_LOG;
This is one way as suggested by Trent.
We can also achieve as follows.
http://www.dba-oracle.com/t_execute_shell_script_plsql_procedure.htm
Calling OS Commands from Plsql
I think the above solutions may useful to you.
Let me know if you are facing any problem.
Thanks and Regards
Maheswara
Maybe you are looking for
-
Report on # of contacts on an opportunity
Hi guys, I have requirement on one of my projects . It needs me to build a report on no. of contacts that are added to and activity . When I pull up a report on Activity History and have the Activity ID , Contact Id columns together , the report only
-
Can't get new macbook air to connect to iPhone 3gs personal hotspot
I set up Personal Hotspot to connect my old MacBook Air to my ATT iPhone 3GS with no problem. (The 3GS connects via Bluetooth.) Then I updated to the new MacBook Air, and now I'm out of luck. The phone and the MBA complete Bluetooth pairing, but that
-
I have just installed Adobe Acrobat 9 Pro Extended and when I try to create a pdf file from an In-Design file I get the following message; Acrobat could not find the application that created this file. Please select a file created by an application t
-
Opening Multiple Files In Adobe XI
In Windows 7 Adobe XI only opens 15 files at a time how do I increase that
-
DB2 backup excluding one table
Hello all, We have AIX 5.3 and DB2 9.1 for our CRM 2007 server. There is a table which contains CVV number. Is it possible to take the backup by excluding that table. Are there any tools that would help in taking backup excluding the table containing