Running Unix commands and scripts from HTML-DB
Hi,
How can I run scripts (like perl scripts) that I have on the UNIX machine that the HTML_DB is installed on.
How for a start can I run even simple UNIX command like "ls" ?
Thanx,
Alon
Alon,
Best to try the database forum and search for "external process" or "extproc" for this - it needs setup for the listener and in the database itself.
You need to be aware - all your commands will be run as the oracle user so you should be very careful who can run them and what commands they can run.
Greg
Similar Messages
-
Problem with shell commands and scripts from an Applescript Application
Hi-
I am fairly new to OSX software development. I am trying to build an application that creates a reverse SSH tunnel to my computer and starts OSXvnc. The idea is that my Mom or anyone else who needs help can connect to me without having to tinker with their firewalls.
There are plenty of resources on how to do this, and I have found them. What I have a problem with is the following.
I am building this application in Xcode as an Applescript application, because Applescript and shell scripting are the only forms of programming I know. I use an expect script to connect through SSH, and a "do shell script" for the raw OSXvnc-server application to allow screen sharing.
The problem is that when I click on the button to launch OSXvnc-server or the button to launch SSH, the application freezes until the process it spawns is killed or finishes. For example, I can set SSH to timeout after 60 seconds of no connection, and then the Applescript application responds again. I even tried using the ssh -f command to fork the process, but that doesn't seem to help.
I am also using "try" around each of the items.
What am I doing wrong? How can I make the buttons in my app launch SSH and OSXvnc-server without hanging the application while it waits for them to finish?
Thanks so much!See here for an explanation of the syntax.
(20960) -
Run Unix command / Run Unix shell script from Forms9i
Hi,
I have a requirement to run Unix command and Unix shell scripts from Forms9i.
I know HOST command cannot be used directly. I also know we can create some JAVA stored procedure to perform the task, but I don't want to create any JAVA stored procedure as there are some security concerns.
Please point me towards any other way to achieve the same.
I would really appreciate your help.
Thanks,
KumarThere is no reason why HOST can't be used. This is what it is for. As for using Java, it is not a stored procedure that you would be using, it would be imported Java (imported into the form).
The best way to use the HOST command is to call a script (.sh) rather than calling a Unix command directly. This is because HOST will not pick up environment variables set at the system level. So the script would first need to set the necessary environment variables then call the desired commands. -
How to run unix command from Oracle Foms 10g
OS: UNIX Solaries, Oracle Application Server 10g
To run shell script from Oracle Forms, I used the following host('/bin/bash /u01/compile.sh') and it works well
Now, I need to run unix command something like
host('mv form1.fmx FORM1.FMX') but it's not working
I tried to append the command "mv form1.fmx FORM1.FMX" to the compile.sh shell script but also it's not working although the rest lines of the shell script is running well
Edited by: slamonty on Aug 23, 2012 12:36 AMYes, Thank you so much, it works well as follow
$ /bin/mv /u01/oracle/runtime/test/form1.fmx /u01/oracle/runtime/test/FORM1.FMX Edited by: slamonty on Aug 23, 2012 9:59 AM
Edited by: slamonty on Aug 23, 2012 11:14 AM -
Running unix commands from within a procedure
Oracle 11.1, AIX 6.1
================
A developer would like to know what the commands are to execute from within a procedure to run unix commands on the database server and capture those results back to the procedure for parsing & manipulation.
Thanks.Don't take this as the correct way to do it, but this is merely 'a' way to do it:
have a db procedure thats executes a db function
create or replace procedure csproc(p_cmd in varchar2)
as
x number;
begin
x:=csfunc(p_cmd);
dbms_output.put_line('x is: '||x);
end;
/The function calls a piece of java to execute the os command and return the return code of the os command
create or replace function csfunc( p_cmd in varchar2) return number
as language java
name 'csclass.RunThis(java.lang.String[]) return integer';
/Here is the java class to run the os command
create or replace and compile java source
named "csclass"
as
import java.io.*;
import java.lang.*;
public class csclass extends Object
public static int RunThis(String[] args)
Runtime rt = Runtime.getRuntime();
int rc = -1;
try
Process p = rt.exec(args[0]);
int bufSize = 4096;
BufferedInputStream bis =
new BufferedInputStream(p.getInputStream(), bufSize);
int len;
byte buffer[] = new byte[bufSize];
// Echo back what the program spit out
while ((len = bis.read(buffer, 0, bufSize)) != -1)
System.out.write(buffer, 0, len);
rc = p.waitFor();
catch (Exception e)
e.printStackTrace();
rc = -1;
finally
return rc;
/and finally the os command - in this case its a very simple shell script
#!/usr/bin/ksh
echo "Hi" >> /app/oracle/workdir/cs.logwill have to grant privileges to my user 'CS' to run the various os commands
exec dbms_java.grant_permission('CS','java.io.FilePermission','/app/oracle/workdir/cs.ksh','read,execute');
exec dbms_java.grant_permission('CS','java.io.FilePermission','/app/oracle/workdir/cs.log','write');
exec dbms_java.grant_permission('CS','SYS:java.lang.RuntimePermission','*','readFileDescriptor');
exec dbms_java.grant_permission('CS','SYS:java.lang.RuntimePermission','*','writeFileDescriptor');and finally can run the procedure from within the db
set serveroutput on
exec dbms_java.set_output(1000000);
exec csproc('/app/oracle/workdir/cs.ksh');
x is: 0
PL/SQL procedure successfully completed.to prove it works ok the logfile shows an entry:
'Hi' -
Running Unix Command from WEB-APPLICATION
Hi all,
I want to run unix command from a java-based web application. the basic code part is this ---
public class RunCommand
public String runIt()
String s = null, returnString = "";
Process p=null;
try
Runtime rt = Runtime.getRuntime();
p = rt.exec("sh testPOC.ksh");
p.waitFor();
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
// read the output from the command
returnString += "Here is the standard output of the command:<br>";
while ((s = stdInput.readLine()) != null) {
returnString += s;
// read any errors from the attempted command
returnString += "Here is the standard error of the command (if any): <br>";
while ((s = stdError.readLine()) != null) {
returnString += s;
catch (IOException e)
returnString += "exception happened - here's what I know: ";
returnString += "error-> " + e.getMessage();
catch(Exception e)
returnString += "exception happened - here's what I know: ";
returnString += "error-> " + e.getMessage();
return returnString;
}this class is kept as an inner class. The control comes to its outer class, from servlet, from which the runit() is called. but the exception is occuring at line of p=rt.exec(.....). it tells "<command name> : not found transaction completed" [got this using getMessage() method].
i am unable to show(and see, too) the stacktrace, because i don't have access to that test environment and its log. i can't run this in local because its windows one.
now can anyone tell me, where is the problem. is there any limitation in web application server/container? this was successful when i used command prompt writing a .java file. Please help me. Thanks in advance...Friends, i've got, where the problem is.
when we run a class file directly from a command prompt, we get an environment with that shell window. but for a servlet application running these kind of commands from a class creates kind of child processes. each and every command is executed as a child process of jvm and don't get those environment. we have 'PATH' variable in the environment. when a command (say, 'dir' or 'sh' or 'ls', etc.) is executed, the shell first search for that executable file (i.e. dir / sh / ls) in the given paths in the variable 'PATH'. this is not available for the child commands of jvm. hence the basic commands are searched in the current directory of the jvm and they are failed.
i solved the problem giving full path of the commands. like :
p = rt.exec("/bin/sh runningScript.ksh") -
I would like to run a unix command and capture the output by running a java program on a windows 98 machine, this will be ran on a secure intranet. What is the best way to do that. If anyone knows of an example source code that would be great.
thanks,
DeanTry this. It always works for me.
import java.io.*;
public class Exec {
private BufferedReader out;
private Process p;
public Exec(String cmd) throws IOException {
p = Runtime.getRuntime().exec(cmd);
out = new BufferedReader(new InputStreamReader(p.getInputStream()));
public BufferedReader getBufferedReader() {
return out;
public void waitFor() throws InterruptedException {
p.waitFor();
public static void main(String [] args) throws IOException,
InterruptedException {
final Exec p = new Exec("your command goes here.");
new Thread(new Runnable() {
public void run() {
try {
String s = null;
while((s = p.getBufferedReader().readLine()) != null) {
System.out.println(s);
catch(IOException io){}
}).start();
p.waitFor();
} -
Adobe Configurator - how to invoke action or script from html widget?
How to invoke action or script from html wiget in Adobe Configurator?
Please help! I tried to make it about 5 hours!
I need something like that:
I click link or image
...and it runs action.
Thanks!If you click on the question mark ( as shown below) on the right of Configurator 2 window
the user guide installed on your computer within Configurator 2 will open
Anyway once you have your action or script button in your panel you must select it and configure it in the inspector palette -
Shell script from HTML DB ?
Hello
I need to call a shell script from HTML DB
Is it possible ?
Either directly or thru PL/SQL code etc ?
Kindly help
ThanksPooja,
Your options are Java stored procedures, run from the database, see:
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:952229840241
Alternatively, you can use external procedures (EXTPROC).
Sergio -
Can we call OS commands and SQLLOADER from pl/sql
Hi,
Please provide me a solution for calling OS commands and SQLLOADER from pl/sqlSee http://www.oracle-base.com/articles/10g/Scheduler10g.php for OS Commands.
Another option for your SQLLoader question would be the use of external tables,
http://www.oracle-base.com/articles/9i/ExternalTables9i.php
C. -
I have a problem to update iMovie 9.0.9. The OS is running really slow and halts from time to time. In the update procedure it says it's one minute left. That was one hour ago... What can I do?
I have a problem to update iMovie 9.0.9. The OS is running really slow and halts from time to time. In the update procedure it says it's one minute left. That was one hour ago... What can I do?
-
Looking to run unix command line from Finder
I want to run a unix command directly from finder. Kind of like using command-G to "Go To Folder".
If a current method isn't supported, I noticed that Terminal.app has a shortcut for "New Command" using command-N. What would be the right way to create a keyboard shortcut in Finder that would call Terminal->New Command?
ThanksYou might use a third-party macro expansion utility that permits creating keyboard macro shortcuts. Examples include QuicKey or iKey. There are also several text expansion utilities that also allow attaching keyboard shortcuts such as TextExpander or Typinator. The above can be found at VersionTracker or MacUpdate.
You can also create an AppleScript using the Do Shell Script command. The resulting compiled script can be attached to an Automator action. I don't know if you can attach a keyboard shortcut but you can add an Automator action to the Services menu and to the Finder's contextual menu. -
Newbie: how to temporary results and handle sessions running UNIX commands?
Hello,
I have just asked a question concerning launching UNIX commands using Java classes, see thread "_https://forums.oracle.com/forums/thread.jspa?threadID=2429211&tstart=0_".
I have followed the mentioned advises (using "bash","-c" parameters) but now I have stumbled into other issues:
My intention is to write a UNIX class, that can handle UNIX commands, in order to be used in other Java programs, so that the following example becomes possible:
UNIX.launch("cd /var/core");
UNIX.launch("rm obsolete_core_file");
UNIX.launch("sqlplus <Oracle_database>");
UNIX.launch("select * from cat;");Unfortunately I have stumbled into a strange behaviour: until now, I have created the UNIX class as a single class, containing a "main" method. When I launch the following commands:
java UNIX "cd /var/core";
java UNIX "rm obsolete_core_file"I have the problem that the "cd /var/core" command is executed while UNIX class is running, but afterwards I jump back to my current directory:
pwd => current directory
java UNIX "cd /var/core" (this is executed, e.g. verifying "ls" output)
pwd => current directoryI would like to have:
pwd => current directory
java UNIX "cd /var/core"
pwd => /var/coreOne other thing is the handling of sessions: until now, when I launch following commands:
UNIX.launch("sqlplus <Oracle_database>");
UNIX.launch("select * from cat;");Then I get into a "sqlplus" session, but afterwards my Telnet session hangs. Is there a way to see that I have fallen into a session, and handle it? (Exit, launch internal session (SQL-plus) command, ...)
Thanks again
Dominiquescampsd wrote:
Hello,
I have just asked a question concerning launching UNIX commands using Java classes, see thread "_https://forums.oracle.com/forums/thread.jspa?threadID=2429211&tstart=0_".
I have followed the mentioned advises (using "bash","-c" parameters) but now I have stumbled into other issues:
My intention is to write a UNIX class, that can handle UNIX commands, in order to be used in other Java programs, so that the following example becomes possible:
UNIX.launch("cd /var/core");
UNIX.launch("rm obsolete_core_file");
UNIX.launch("sqlplus <Oracle_database>");
UNIX.launch("select * from cat;");Unfortunately I have stumbled into a strange behaviour: until now, I have created the UNIX class as a single class, containing a "main" method. When I launch the following commands:
java UNIX "cd /var/core";
java UNIX "rm obsolete_core_file"I have the problem that the "cd /var/core" command is executed while UNIX class is running, but afterwards I jump back to my current directory:
pwd => current directory
java UNIX "cd /var/core" (this is executed, e.g. verifying "ls" output)
pwd => current directoryI would like to have:
pwd => current directory
java UNIX "cd /var/core"
pwd => /var/coreOne other thing is the handling of sessions: until now, when I launch following commands:
UNIX.launch("sqlplus <Oracle_database>");
UNIX.launch("select * from cat;");Then I get into a "sqlplus" session, but afterwards my Telnet session hangs. Is there a way to see that I have fallen into a session, and handle it? (Exit, launch internal session (SQL-plus) command, ...)
Thanks again
DominiqueWhy not just use plain java File I/O http://docs.oracle.com/javase/tutorial/essential/io/fileio.html and JDBC http://docs.oracle.com/javase/tutorial/jdbc/basics/processingsqlstatements.html for fulfilling your requirements?
Edited by: maheshguruswamy on Aug 20, 2012 10:32 AM -
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. -
Can we run a stored proc script from Unix console?
Hello all:
One of my colleagues insists that she used to run a stored proc file, say, abc.proc from a Unix console, with some command. I suspect the "command" is actually a script that invokes sqlplus commands. I never knew a stored proc script can be ran by any built-in Unix command, other than that in sql*plus console.
Anyone can prove me wrong?
Thanks,
JohnnyHi Johnny,
Unix shell doesn't have any means of compiling and/or executing PL/SQL code. You need a client (a driver) to make database calls, like sqlplus. So I think your assumption is correct.
Best regards,
Nikolay
Maybe you are looking for
-
"Accessing iTunes Store" box pops up every time I click on something new on itunes
When I open itunes it automatically tries to connect to the itunes store but the "connecting to itunes store" status bar keeps popping up even after it has connected. I'm unable to navigate the itunes store without this status bar popping up. I've
-
After restoring from Time Machine onto a new Mac, all images in Aperture are now just outlined. Aperture can't find the volume of the master images because that was the volume of my old Mac. Is there any way to tell Aperture to reconnect with the mas
-
can firefox support "file:///" format to access local files (note 3 fw slashes) this works for IE but not firefox and is the format used in the "afghan war diary" from wikileaks
-
ILife 08- problem with Podcast and Blog links on landing page
Hello I have iLife 08, running OS 10.4.11. The Podcast and Blog links on my iWeb landing page appear but don't do anything. All was working fine one week ago. They load, and when you mouse over it the links looks like they are going to work but don't
-
Photo Sort in iPhone/iPad albums?
Hi, I'm about to lose my mind... how do I get my photo's to come up as newest first, in all of my albums? One would think that there should be a "sort" button on either device, right? I'm running Windows 7, on my pc and own a iphone 5s and ipad min