Executing a shell script from a form (client / server)
From a form in a client server environment, I would like to execute a shell script on the server.
Environment:
Server: SunOS 5.6
DB : 8.0.5
Forms : Developer 6 w/patch 6A
Forms - 6.0.5.34.0
Jim,
Yes. Use the host command from forms and call the command rexec.
Raymond
null
Similar Messages
-
Executing a shell script from a java program
Hi,
I'm facing a problem while executing a shell script from a jsp page.
I'm using exec() function.
It's working fine for single statement scripts.But if the script consists of any database processing and some other processing statements,it's not returning the correct exit status of the process.
Will u please help me in this.
If there is any other ways to execute a shell script from a jsp page other than Runtime.exec().If so let me know.
Thanks in advance.I think this shud workMaybe - but it is wrong! Why do you create aReader
and then read bytes which are turned into a String
without worrying about whether or not the bytes area
String and without worrying about the character
encoding if the bytes do represent characters and
without worrying about how many bytes wereactually
read.
Also, both you and the OP should read, digest and
follow the advice given in
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-
traps.htmlI dont care if it is wrong. This code works for me.
We are here to solve problems not to find which post
is wrong.It is wrong! You are posting bad advice that is very wrong! It may work for you but it is wrong in general! WRONG WRONG WRONG.
If you have a solution then post it I did post a solution! The reference I gave will explain to you and the OP exactly how it should be done.
rather then
posting rude comments.I was not rude! I was explaining just some of what was wrong! -
Executing a shell script from a jsp page
Hi,
I'm facing a problem while executing a shell script from a jsp page.
I'm using Runtime.exec() function.
It's working fine for single statement scripts.But if the script consists of any database processing and some other processing statements,it's not returning the correct exit status of the process.
Will u please help me in this.
If there is any other ways to execute a shell script from a jsp page other than Runtime.exec() like RMI etc,.If so let me know.
Thanks in advance.Hello,
It's hard to help you but what you can do is listening to the outputs of your script, you should read the output stream and error stream and send them to the default console.
Check this excellent article : http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?page=4
Best regards,
Olivier. -
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 we can call or execute a SHELL script through Oracle forms or Reports
How we can call or execute a SHELL script through Oracle forms or Reports.Its urgent.......
Use HOST command.
-
Call a shell script from ActiveSync form?
Hi,
I need to call a shell script from an ActiveSync form . How can I do this.
I want to execute shell script at time of account create, update, delete.
ThanksI would probably accomplish this by calling the shell script via java, and invoking the java code via xpress code in your ActiveSync form.
-
Execute a shell script from inside PL procedure
Oracle 9205 on Red Hat Enterprise Linux 3.
Is there any way to execute an O.S. shell script from inside a PL/SQL procedure?
This is, that PL_SQL procedure evaluate a situation and if the condition is true, it calls and execute an O.S. shell script.PL/SQL procedures do not support any native calls to the OS; however, you can code calls to external procedures or JAVA procedures to perform tasks on the OS.
Prior to these two methods any of the following packages dbms_alert, dbms_pipe, or utl_file could be combined with a daemon type program to issue OS commands, run shell scripts, etc....
There is a writeup on metalink with examples.
HTH -- Mark D Powell -- -
Example: Executing a shell script from java
Hi. There are many other posts in the forums related to executing a unix script from java, but I wanted to post another example that I thought might be helpful...
The key thing to executing the script is to include the -c switch for the sh command. This tells the sh command that you are passing a string to be interpreted as input. Without this switch, the script does not execute as you'd expect it to. Also, use a string array to pass each part of the sh command.
Here is a working sample class, along with a test script to execute it:
public class TestShellScript {
public static void main(String[] args)
String[] chmod = {"chmod","777","testscript1"};
String[] runscript = {"sh","-c","./testscript1 > jdata.out"};
Runtime rtime = Runtime.getRuntime();
try
rtime.exec(chmod); // Set the authorities for testing
rtime.exec(runscript); // Run the script with redirection
catch (IOException e)
e.printStackTrace();
rtime = null;
Here is a test script to wrap the java call:
#!/bin/sh
cd /<your script dir>
export -s CLASSPATH=/<your jar dir>/TestShellScript.jar
export -s PATH=/<your script dir>:/usr/bin
java TestShellScript
- Hope this helps.I don't know exactly but the code written below is working fine try the same with your code .Even with your code instead running the code with
" ./<filename> ",if you execute it with "sh <filename>" command without changing the mode of the file it is executing properly.
import java.io.*;
import java.util.*;
public class ScriptBuilder
public ScriptBuilder()
public void writeScript() throws java.io.IOException
FileWriter writer = new FileWriter(new File("test_script"));
writer.write("#! /bin/sh\n");
writer.write("ll>/home/faiyaz/javaprac/checkll");
writer.flush();
writer.close();
Runtime rt= Runtime.getRuntime();
rt.exec("chmod 777 test_script");
rt.exec("./test_script");
} public static void main (String[] args)throws java.io.IOException
ScriptBuilder sb = new ScriptBuilder();
sb.writeScript();
} -
Executing a shell script from a web deployed form
Hi there,
i've got a web deployed form from which i want to execute a UNIX shell script upon clicking a button.. I've used the host command ,and the rsh utility in Windows NT but i'm getting an error message saying
"machine address" Permission denied, rsh can't establish connection " this is the code in the when button pressed trigger
HOST('c:\windows\system32\rsh <<machine address>> opt/apps/wmc/rw.ksh');
the machine address being the unix machine i'm trying to connect to and the last part being the path and the shell script to be executed..
can anybody help me out here ????
Regards
wole
nullJim,
Yes. Use the host command from forms and call the command rexec.
Raymond
null -
Executing a shell script from pl/sql stored procedure
Hi,
I have Oracle 8i on HP-UX.
I am passing a shell script name as a parameter to a user defined function from a pl/sql stored procedure. This user defined function has insterface to a user defined Java class file in Aurora java virtual machine which is written using runtime class which can execute any OS command or any shell script. I am getting any OS command run successfully, but could not run my own shell script. It's is not getting environment variables of my own, so not getting executed. So please suggest how can get these env variables in my shell script and also suggest other sucurity concerns to be taken into consideration.
If you have any questions please let me know.
This is really a very urgent issue.....
Please help me.
Thanks
Srinivasa Rao KollaYour best bet is to use the dbms_pipe builtin package to send the command to the host
-
Executing a shell script from a Trigger
All,
I have to write a script to do the following requirement.
There is a file called BUSINESS_DATE.TXT.
This file get updated once the oracle partition created. In Oracle, Partition will be created every day. There is a seperate script scheduled to take care ORACLE partition creation.
The above file will have only one row. i.e
03092012
If Oracle partition creation job failed, the above file won't be updated.
My requirement is,
I have to check whether the BUSINESS_DATE file is updated today or not. If yes, I will have to move the files from common area to input file directory to process those files.
All file name will amend with current date.
i.e
LIDDIFD03092012.TXT
The key part is to check the BUSINESS_DATE.TXT file is updated properly or not.
We don't know what time the file will get updated. So we are planning to schedule the new script to run for every 15 mins to check whether the file is updated or not
But...I just thougt instead of writing a shell script to do the above one, Why shouldn't I capture the date in a table (New table needs to be created) and use ORACLE TRIGGER to run the shell script to move the files from common area to input file directory to process those files?
My Proposal in ORACLE :
Create table business_date
rep_date varchar(15),
curr_timestamp timestamp
Once the oracle partition created , one row will be inserted into the above table. This adjustment needs to be implemented partition script.
Once this table get record, TRIGGER should call SHELL SCRIPT to move the files from common area to input area.
If I implement ORACLE TRIGGER, The script which will check whether the file got updated or not for 15 mins is not required. Right? Inputs from experts are welcome!>
But...I just thougt instead of writing a shell script to do the above one, Why shouldn't I capture the date in a table (New table needs to be created) and use ORACLE TRIGGER to run the shell script to move the files from common area to input file directory to process those files?
>
Triggers should not be used to do transactional work. There is no COMMIT in a trigger. What happens if the trigger runs the shell script and then a ROLLBACK occurs? You will have run the shell script when it shouldn't run.
Create a stored procedure to run the shell script. Call the stored procedure when the partition is created.
If you were using 11g and interval paritioning you wouldn't need to create the partitions manually. Oracle could create the partitions automatically. -
Executing a shell script from java using runtime.exec()
Hi I am trying to create a script (test_script) and execute it -- all within one java program...
the code compiles and executes perfectly but nothing happens. This is probably because the script does not get changed to the '777' mode although i am trying to do that ... any suggestions ???
//code
import java.io.*;
import java.util.*;
public class ScriptBuilder
public ScriptBuilder() {
public void writeScript() throws java.io.IOException{
FileWriter writer = new FileWriter(new File("test_script"));
writer.write("#! /bin/sh\n");
writer.write("cd prodiags\n");
writer.write("tar cvf delTask.tar delTask\n");
writer.write("rm -rf delTask\n");
writer.flush();
writer.close();
Runtime rt= Runtime.getRuntime();
String[] cmd = new String[3];
cmd[0] = "ls";
cmd[1] = "chmod 777 test_script";
cmd[2] = "./test_script";
rt.exec(cmd);
public static void main (String[] args)throws java.io.IOException
ScriptBuilder sb = new ScriptBuilder();
sb.writeScript();
}I don't know exactly but the code written below is working fine try the same with your code .Even with your code instead running the code with
" ./<filename> ",if you execute it with "sh <filename>" command without changing the mode of the file it is executing properly.
import java.io.*;
import java.util.*;
public class ScriptBuilder
public ScriptBuilder()
public void writeScript() throws java.io.IOException
FileWriter writer = new FileWriter(new File("test_script"));
writer.write("#! /bin/sh\n");
writer.write("ll>/home/faiyaz/javaprac/checkll");
writer.flush();
writer.close();
Runtime rt= Runtime.getRuntime();
rt.exec("chmod 777 test_script");
rt.exec("./test_script");
} public static void main (String[] args)throws java.io.IOException
ScriptBuilder sb = new ScriptBuilder();
sb.writeScript();
} -
Execute Shell Script from OWB Process Flow
I am trying to execute a Shell Script from a User Defined activity of OWB Process Flow. As I have not done such things earlier
I need to know:
1. Where I will put the Shell Script (move_file.sh)?
2. What are the values in need to enter in the external process parameters (such as Command, Script, Result Code, Parameter List, Sucess Threshold etc)
Please reply this thread. It would be a big help for me and probably for others as well.
Kind Regards
Zakir
Message was edited by:
ZakirCheck this out,.
http://download-uk.oracle.com/docs/cd/B31080_01/doc/owb.102/b28223/ref_processflows.htm#i1173362
And answer to your question1, the shell script should be on the unix server.
Regards -
How to execucte/calll a shell script from oracle
hi all
i want to execute a shell script from oracle...... how do i do that can any one send me a good link which i can refer and learn
or if any one has already implemented anything like this plz let me know the code
RegardsHere u goooooo
http://www.experts-exchange.com/Database/Oracle/Q_21908413.html
Regards,
http://www.oracleracexpert.com
Send email using UTL_MAIL in oracle.
http://www.oracleracexpert.com/2009/11/send-email-using-utlmail-in-oracle-10g.html
Migrate Non-ASM Database to ASM using RMAN
http://www.oracleracexpert.com/2009/10/migrate-database-to-asm-using-rman.html]
Maybe you are looking for
-
Restrict multiple log in with same user ID
I have a JSF Project where I use Oracle JAAS for Login. The login works perfectly and also the components on the JSF page shows as per User Role. I am using OAS 10.1.3.3. I want to now implement the code so as to restrict simultaneous logins with the
-
When I open Firefox it is suppose to take me to my Yahoo home page. But it opens up showing my wifes Yahoo sigh in page in stead of mine. Having trouble with Yahoo home page sign in. Some time it brings up my wife's Yahoo log in instead of my log in
-
Calling a JavaScript function from my class
Here's the situation. I am trying to access a website (not my own) through a class I am writing. Some information that I need to pull off the page can only be seen when a JavaScript function is called. How can I make the page call the function from m
-
I am trying to use Access Connections to automatically switch my location profiles, i have 2 problems though: 1. every time I plug in my computer to the lan, first I receive an IP properly, then access connections seems to be siwtching profiles and t
-
Split a ";" delimited record using SQL
Post Author: GraemeG CA Forum: Data Connectivity and SQL I receive a string of semi-colon delimited data output by a third-party system. The idea is to drag this record into Crystal and match it up to some reference information in our database and th