Running a command from local zone in global zone
hi,
Does anyone have a document on how I can tunnel into the global zone, run a command and receive the return value in the global zone? I am sure that there should be a mechanism for that but couldn't find any.
Thanks,
Babak
That's the opposite of what you asked in your first post. The global zone can run commands in non-global zones with zlogin.
global# zlogin zone-a /path/to/command" | ...
global# zlogin zone1 zonename
zone1
global# zonename
global{code}
Darren
Similar Messages
-
Running CLIX commands from local machine
Hello Experts,
We have the following requirements in terms of clix commands
Need to know the number of files in log/archieve/report folder - Is there any clix commands for this
Want to run the clix commands manually from local machine (Windows), the mdm server is at linux environment. We dont want to automate the script and want to run when needed from local machine. Is that possible
Thanks & Regards,
AntonyHI,A.Antony
as far as i know ,clix can not count the number of files in the loglog/archieve/report folder.but there is a way out.you can get through the path:<driver>:\usr\sap\<instance>\MDS00\log to check it out.
to run clix locally,you need to install the mdm-clix-7.1.<sp>.<patch>-win32.exe on your windows.then run the clix in the cmd circumstance.for the clix command Syntax,please refer to the MDM console reference guide,as for MDM7.1SP12,you may goto the Clix referece guide on help.sap.com.
hope it helps.
best regards
Stephen -
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") -
Running ssh command from java and then answering password prompt
Hi,
I have a situation that has not solved yet. I am running ssh command from unix terminal without any problem, and then i enter password.
For example :
[oracle@fuata]:/export/home/oracle> ssh -N [email protected] -L 9901:127.0.0.1:9999
Password:
It is working. I have question that how can i perform this in java? I am thinking that i can run ssh command by using Runtime Class, it is ok. But how can i answer the password? I am a bit confused. Is there any example looks like this?
Thanks for responses.futi wrote:
Thanx. Firstly i insisted to do this without jsch but actually this is harder than jsch. I edit some of code pieces PortForwardingL.java and could run it. It works problem-free. Could you say why you "insisted" on this approach. It can't be for speed+ since jsch is very fast. It can't be for portability+ since jsch is portable but the use of Runtime.exec() requires the installation of ssh software. It can't be because of limitations+ since jsch is a fully featured library. It can't be for security+ since jsch is secure. It can't be for ease of use+ since jsch is much easier to use than ssh with Runtime.exec(). Unless it's a licensing issue, it can't be for commercial+ reasons since jsch is free. The only reason I can think of why one would "insisted" on this approach is if it is for some college project. -
Running ls command from Java stroed procedure no output
Hi ,
I am trying to run ls command from java stored procedure in oracle
Process p = Runtime.getRuntime().exec("ls");
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
// read the output from the command
System.out.println("output of the command run:\n");
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
from java stored procedure in oracle.
i get output of println statments but it does not go into while loop to print from stdInput.
Result of running Java stored procedure is -
output of the command run:
Call completed.
when i run the program on client side it works fine.
Has anybody tried this from java stroed procedure.
Thanks,
JagJag,
Actually, the question of whether it works for me seems to depend on the version of the OS (or Oracle). On RedHat Linux (Oracle 8.1.6) it didn't work at all, but on Solaris (Oracle 9.0.2) it did. Here's the output from that run:
SQL> /
output of the command run:
init.ora
initDBPart9i.DBPSun01.ora
initdw.ora
lkDBPART9I
orapw
orapwDBPart9i
spfileDBPart9i.ora
Done
PL/SQL procedure successfully completed.
But, I did need to change a line of your code to this:
Process p = Runtime.getRuntime().exec("/usr/bin/ls");
your original was:
Process p = Runtime.getRuntime().exec("ls");
You might consider, if possible, use of some of the Java File classes instead of ls, as this might make things more predictable for you. There were some examples in oramag.com a few months ago, but they were pretty simple (you might not need them).
Hope this helps,
-Dan
http://www.compuware.com/products/devpartner/db/oracle_debug.htm
Debug PL/SQL and Java in the Oracle Database -
Hi All!!
Which package can help me to run OS command from SQL script?
Thanks.If you are using SQL*Plus to execute the script, you can use the SQL*Plus command HOST. If you are trying to execute an operating system command from a PL/SQL block (i.e. a stored procedure), you would need to use an external procedure or a Java stored procedure that uses Java's shell functionality.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Is it possible to run host command from SAP environment? How do you run?
Hi
Is it possible to run host command from SAP environment? How do you run?
Thank YouHello Subhash
You will more details in the following thread:
Re: How to define command for SXPG_COMMAND_EXECUTE
Regards
Uwe -
Running sqlldr command from PL/SQL Block
DECLARE
BEGIN
END;In SQL * plus we can run DOS commands using the following command
HOST DIR
HOST DIR/P
But When we can't run the HOST command in PL/SQL Block..
I have to Run sqlldr command from PL/SQL Block..
i tried as follows
DECLARE
BEGIN
EXECUTE IMMEDIATE ' host sqlldr control= bad= ';
END;
By
BalaNagaRaju -
How to run OS commands from PL/SQL???
Hi
Is there any way to run OS commands(Windows Platform) from within PL/SQL?
ThanksAPC,
I am working on Discoverer, having lots of BAs & Workbooks created & stored in Database. Now if i want to move all the workbooks from one place to another (like from development to test or production) i can use Command line interface of Disco to do this. But i don't see any option there to export all the workbooks, so i thought of writing a pl/sql to get all the workbook names from the EUL then fire export Command for each record(although not a good practice but its a one time work). This is the place where i need to run OS command from within PL/SQL. Although it doesn't seem possible now(as you all said) without external procedure.
Lastly, you are right that "Oracle make databases not operating systems" but my first impression/comment about oracle is:
"Oracle is far Bigger, Powerful, Complex, Vast and Interesting System than any other..." so i believe it can do/capable doing anything :-)
thx Ashutosh,
Host is definitely an option but i can't run it from pl/sql(that i am looking for).. -
Running curl command from a java program using Runtime.getRuntime.exec
for some reason my curl command does not run when I run it from within my java program and errors out with "https protocol not supported". This same curl command however runs fine from any directory on my red hat linux system.
To debug the problem, I printed my curl command from the java program before calling Runtime.getRuntime.exec command and then used this o/p to run from the command line and it runs fine.
I am not using libcurl or anything else, I am running a simple curl command as a command line utility from inside a Java program.
Any ideas on why this might be happening?thanks a lot for your response. The reason why I am using curl is because I need to use certificates and keys to gain access to the internal server. So I use curl "<url> --cert <path to the certificate>" --key "<path to the key>". If you don't mid could you please tell me which version of curl you are using.
I am using 7.15 in my system.
Below is the code which errors out.
public int execCurlCmd(String command)
String s = null;
try {
// run the Unix "ps -ef" command
Process p = Runtime.getRuntime().exec(command);
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
// read the output from the command
System.out.println("Here is the standard output of the command:\n");
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
// read any errors from the attempted command
System.out.println("Here is the standard error of the command (if any):\n");
while ((s = stdError.readLine()) != null) {
System.out.println(s);
return(0);
catch (IOException e) {
System.out.println("exception happened - here's what I know: ");
e.printStackTrace();
return(-1);
} -
hi I am using this code which needs to copy file
import java.io.File;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class RunSystemCommand {
public static void main(String args[]) {
String s = null;
// system command to run
String cmd = "copy a.txt b.txt";
// set the working directory for the OS command processor
File workDir = new File("c:
temp");
try {
Process p = Runtime.getRuntime().exec(cmd, null, workDir);
int i = p.waitFor();
if (i == 0){
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
// read the output from the command
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
else {
BufferedReader stdErr = new BufferedReader(new InputStreamReader(p.getErrorStream()));
// read the output from the command
while ((s = stdErr.readLine()) != null) {
System.out.println(s);
catch (Exception e) {
System.out.println(e);
it doesnt work,the error is
java.io.IOException: CreateProcess: copy a.txt b.txt error=2
thx,ShaiIf you are using SQL*Plus to execute the script, you can use the SQL*Plus command HOST. If you are trying to execute an operating system command from a PL/SQL block (i.e. a stored procedure), you would need to use an external procedure or a Java stored procedure that uses Java's shell functionality.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
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 -
Problem while running dos command from java program
Dear friends,
I need to terminate a running jar file from my java program which is running in the windows os.
For that i have an dos command to find process id of java program and kill by using tskill command.
Command to find process id is,
wmic /output:ProcessList.txt process where "name='java.exe'" get commandline,processid
This command gives the ProcessList.txt file and it contains the processid. I have to read this file to find the processid.
when i execute this command in dos prompt, it gives the processid in the ProcessList.txt file. But when i execute the same command in java program it keeps running mode only.
Code to run this command is,
public class KillProcess {
public static void main(String args[]) {
KillProcess kProcess = new KillProcess();
kProcess.getRunningProcess();
kProcess = new KillProcess();
kProcess.readProcessFile();
public void getRunningProcess() {
String cmd = "wmic /output:ProcessList.txt process where \"name='java.exe'\" get commandline,processid";
try {
Runtime run = Runtime.getRuntime();
Process process = run.exec(cmd);
int i = process.waitFor();
String s = null;
if(i==0) {
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(process.getInputStream()));
while ((s = stdInput.readLine()) != null) {
System.out.println("--> "+s);
} else {
BufferedReader stdError = new BufferedReader(new
InputStreamReader(process.getErrorStream()));
while ((s = stdError.readLine()) != null) {
System.out.println("====> "+ s);
System.out.println("Running process End....");
} catch(Exception e) {
e.printStackTrace();
public String readProcessFile() {
System.out.println("Read Process File...");
File file = null;
FileInputStream fis = null;
BufferedReader br = null;
String pixieLoc = "";
try {
file = new File("ProcessList.txt");
if (file.exists() && file.length() > 0) {
fis = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(fis, "UTF-16"));
String line;
while((line = br.readLine()) != null) {
System.out.println(line);
} else {
System.out.println("No such file");
} catch (Exception e) {
e.printStackTrace();
return pixieLoc;
} when i remove the process.waitFor(), then while reading the ProcessList.txt file, it says "No such file".
if i give process.waitFor(), then it's in running mode and program is not completed.
Colud anyone please tell me how to handle this situation?
or Is there anyother way to kill the one running process in windows from java program?
Thanks in advance,
SathishHi masijade,
The modified code is,
class StreamGobbler extends Thread
InputStream is;
String type;
StreamGobbler(InputStream is, String type)
this.is = is;
this.type = type;
public void run()
try
InputStreamReader isr = new InputStreamReader(is, "UTF-16");
BufferedReader br = new BufferedReader(isr);
String line=null;
while ( (line = br.readLine()) != null)
System.out.println(type + ">" + line);
} catch (IOException ioe)
ioe.printStackTrace();
public class GoodWindowsExec
public static void main(String args[])
try
String osName = System.getProperty("os.name" );
String[] cmd = new String[3];
if( osName.equals( "Windows 95" ) )
cmd[0] = "command.com" ;
cmd[1] = "/C" ;
cmd[2] = "wmic process where \"name='java.exe'\" get commandline,processid";
} else {
cmd[0] = "cmd.exe" ;
cmd[1] = "/C" ;
cmd[2] = "wmic process where \"name='java.exe'\" get commandline,processid";
Runtime rt = Runtime.getRuntime();
System.out.println("Execing " + cmd[0] + " " + cmd[1]
+ " " + cmd[2]);
Process proc = rt.exec(cmd);
System.out.println("Executing.......");
// any error message?
StreamGobbler errorGobbler = new
StreamGobbler(proc.getErrorStream(), "ERROR");
// any output?
StreamGobbler outputGobbler = new
StreamGobbler(proc.getInputStream(), "OUTPUT");
// kick them off
errorGobbler.start();
outputGobbler.start();
// any error???
int exitVal = proc.waitFor();
System.out.println("ExitValue: " + exitVal);
} catch (Throwable t)
t.printStackTrace();
}when i execute the above code, i got output as,
Execing cmd.exe /C wmic process where "name='java.exe'" get commandline,processid
and keeps in running mode only.
If i execute the same command in dos prompt,
CommandLine
ProcessId
java -classpath ./../lib/StartApp.jar;./../lib; com.abc.middle.startapp.StartAPP 2468
If i modify the command as,
cmd.exe /C wmic process where "name='java.exe'" get commandline,processid > 123.txt
and keeps in running mode only.
If i open the file when program in running mode, no contents in that file.
If i terminte the program and if i open the file, then i find the processid in that file.
Can you help me to solve this issue? -
Running java command from DOS prompt
Hi,
When I run java from the DOS prompt (NT) in any other location than the JDK bin directory, I get the following error:
Error opening registry key 'Software\JavaSoft\Java Runtime Environment'
My understanding is to be able to run this from anywhere you need to add the tools.jar file to the CLASSPATH, which I have done.
There is no entry in the Registry for Software\JavaSoft...etc, has anyone any idea what my problem is and how I can solve it?
Thanks in advanceHi,
I am running Java 2 SDK, Standard Edition Version 1.2.2 running on NT. It was installed as part of Oracles JDeveloper IDE and is running on NT.
All I want to be able to do is run java from the command line e.g. 'java myclass', to run a standalone Java program. I can run 'javac myclass.java' to compile the program without any problems, but my understanding is that to do this all I need is to have the '.../java1.2/bin' directory included in the 'PATH' variable, whereas to run the java runtime you need to include the tools.jar in the CLASSPATH variable.
As I said previously I can run the 'java myclass' command from the '../java1.2/bin' directory, just not from anywhere else. As for whats in the code, does not matter you should be able to type just java on the command line and it will come back with an error prompting for the class name. Here is an example of what happens:
I:\>java
Error opening registry key 'Software\JavaSoft\Java Runtime Environment'
However if I change to the correct directory, I get:
D:\oracle\JDev32\java1.2\bin>java
Usage: java [-options] class [args...]
(to execute a class)
or java -jar [-options] jarfile [args...]
(to execute a jar file)
where options include:
-cp -classpath <directories and zip/jar files separated by ;>
set search path for application classes and resources
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version
-? -help print this help message
-X print help on non-standard options
The contents of my PATH and CLASSPATH variable are shown below, Thanks again.
I:\>PATH
PATH=D:\oracle\BIN;D:\oracle\Apache\Perl\5.00503\bin\mswin32-x86;C:\Program Files\Oracle\jre\1.1.7\b
in;D:\oracle\ora8i\bin;C:\DMINT40\Win32\Bin;C:\WINNT\system32;C:\WINNT;C:\Program Files\Symantec\pcA
nywhere;d:\oracle\jdev32\java1.2\bin;d:\downloads\oraxml\bin;d:\oracle\jdev32\java1.2\lib\tools.jar
I:\>echo %CLASSPATH%
d:\oracle\jdev32\java1.2\lib\tools.jar;d:\oracle\apache\apache\htdocs\web-inf\classes;d:\oracle\apac
he\jserv\servlets -
Hellow,
Can Any Anyone tell me how to run an Operating System Command From SQL ???
Or From Developer 6i ??
Regards
TariqUse Host command
Maybe you are looking for
-
Adobe CQ5.5 Digital Asset - Delete default metadata and how to create custom metadata
Hi I am trying to create custom metadata for all format of assets (PDF, DOC, TXT, etc.,). I have created the dam folder under apps node as below:- Step 1: /apps/dam/content/asseteditors/formitems Step 2: Included the four property as textfield and
-
Hello, first thing: sorry for my poor english. I'm running PS6 (CS6 Design Standard) on Mac OS Mavericks, all up to date. And there is some problem with printing: cmd+P results with "There was an error opening your printer. Printing functions will n
-
Reg Alerts using with & without BPM.
Dear Experts, The flow of the inbound message is Customers>( Seeburger Adapter which receives the message and passes to the integration of XI CENTRAL HUB) CENTRAL XI HUB> XI HUB-->SAP System and the out bound is viceversa. 1. A Message fai
-
How to append content in begining of text file?
i want to append content in the begining of text file. (usually append flag will append content in end of the file) is there any class in java support this need? if there is no class for this...anybody can give logic to implement venu
-
Firefox will not open on my pc. When I click on it, the icon runs then nothing further happens. I tried to uninstall it and a popup box tells me to turn off firefox before it will let me uninstall. Likewise if I just try and install. Firefox is not o