Unix SYSTEM command
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?
Thanks
While sending the message, you would use PACK_MESSAGE and SEND_MESSAGE:
This could be your PL/SQL procedure.
DBMS_PIPE.PACK_MESSAGE('<Your Message>');
return_code := DBMS_PIPE.SEND_MESSAGE
(pipename => '<Any unique legal identifier as pipe-name>'
,timeout => (1*60)) ;
if (return_code <> 0)
then
Raise_Application_Error(-20100, 'Error sending message.') ;
end if ;
While reading the message, you would use RECEIVE_MESSAGE and UNPACK_MESSAGE:
This could be with-in your target PL/SQL code, or Java function or a C/Pro*C program.
return_code := DBMS_PIPE.RECEIVE_MESSAGE
(pipename => '<pipe-name used when calling SEND_MESSAGE>'
,timeout => 10);
IF return_code = 0
THEN
DBMS_PIPE.UNPACK_MESSAGE(<variable to receive the message>);
ELSE
No message received, wait for a while and try again.
DBMS_LOCK.SLEEP(30) ;
END IF ;
Let me know if you need more info on this.
Kamal,
Would you mind sharing some example code for using DBMS_PIPE to execute OS commands with in PL/SQL?
Thx,
SriDHAR
Similar Messages
-
Help! How to call Unix system command?
In my java application.there are some code as following:
try{
String cmd = "ls -a > temp.txt";
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(cmd);
int rc = process.exitValue();
if (rc == 0){
System.out.println("OK!");
else{
System.out.println("Failed!");
catch(Exception ex){
ex.printStackTrace();
But when i run the application, it always throws IllegalTreadStateException,
return code(rc) is 2, exception's content is as below:
java.lang.IllegalThreadStateException: process hasn't exited
at java.lang.UNIXProcess.exitValue(UNIXProcess.java:118)
at MyApplication.main(...)
If someone know what happened, please help me, my E-mail address is:
[email protected]import java.io.*;
public class RunCommand {
public static void main(String args[]) {
String s = null;
try {
// run the Unix "ps -ef" command
Process p = Runtime.getRuntime().exec("ps -ef");
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);
System.exit(0);
catch (IOException e) {
System.out.println("exception happened - here's what I know: ");
e.printStackTrace();
System.exit(-1);
http://www.devdaily.com/java/edu/pj/pj010016/index.shtml
Cheers,
Bala -
Integrate unix system calls in htmldb display
can you please show what have to be done to display unix system command in htmldb. for example - how can i show the output for the "ls" unix command in htmldb ?
Please direct to some examples.
ThanxIf there is a command line tool then you use Runtime.exec() otherwise you have to use JNI.
If you want to access shared libraries you might want to look at www.swig.org -
How to execute a system command on a remote UNIX server?
I would like to execute a system command (for example "df") on a remote UNIX machine.
A simple example would be welcome...
ThanksI would like to execute a system command (for example
"df") on a remote UNIX machine.
A simple example would be welcome...None will be forthcoming.
Executing a process is relatively simple. However doing this on a remot system is another matter.
See http://sourceforge.net/projects/sshtools/
and/or http://javassh.org/space/start
Other resources to be found with Google. -
Running a command by Runtime class on Unix system
Hi,
To run a command in Windows I wrote the following code:
String s = "cmd.exe /C " + AnyCommand;
Process p = Runtime.getRuntime( ).exec( s );
For Unix system, what do I need to replace the "cmd.exe /C"?
Thank youI am not familiar with Unix.
I've tried "bash", but that diesn't work
The AnyCommand is a compiling command "javac
className.java"Well, javac is an executable. So you don't need a command shell around it to run it, unless you want certain things like redirecting standard output to a file, such that the command shell provides. Just pass "javac className.java". (Now next question will be why doesn't it work, because you also have to take into account the current directory from which you launched javac, and so forth) -
How to create OID attributes from command line in unix system
Hi,
I have to create OID attributes through ldif files in unix system. I dont know how to run it in unix system under which folder. I already have ldif files for creating OID attributes. Please help.Hi,
unser the /your_ODI_HOME/agent/bin folder.
Excute this
sh startscen.sh REFRESH_ID 001 GLOBAL 5 -NAME=agent_ODI
REFRESH_ID=Your Scenario name
001:Version
GLOBAL:Context name
5=Log Level
agent_ODI=Your agent name
Regards -
How to Run Operating System Command Before/After Message Processing SAP PI
Hi,
We are trying to execute multiple commands via "Operating System Command Before/After Message Processing".
When we use single command say for example cp or mv (copy or move) the commands get executed fine.
eg: cp %F /var/opt/data/outbound/Test/Dummy.txt
/this works fine/
when we club commands together or try to redirect the outputs of commands, none of the commands get executed.
eg:
cp %F /var/opt/data/outbound/Test/Dummy.txt ; rm %F
or
wc -l %F > /var/opt/data/outbound/Test/Dummy.txt
Is it possible to execute multiple commands or redirect the output of commands without using a shell script? The PI server we are working on iis hosted on UNIX environment.Hi Harleen,
try like this
cp %F /var/opt/data/outbound/Test/Dummy.txt ; rm %F
instead of semicolon try this
(1) &
command1 & command2
Execute Command1 and then execute Command2
(2) &&
command1 && command2
Runs the command2 only when command1 doesn't Complete successfully
(3) ||
command1 || command2
Runs the second command if the first command had an error
(4) ()
(command1 || command2) || (command3 & command4)
Defines the order in which commands are to be executed
Regards
Suraj -
To emulate the "clrscr" command (from C), I am determining the name of the OS and then passing the appropriate command to the Runtime object:
if ((menu.osName.lastIndexOf("sun") != -1) || (menu.osName.lastIndexOf("inux") != -1))
System.out.println("This is an unix terminal");
menu.clearCommand = "/usr/bin/clear";
else if (menu.osName.lastIndexOf("indow") != -1)
System.out.println("This is a Windows MS-DOS terminal");
menu.clearCommand = "C:\\Windows\\Command\\cls";
else if (menu.osName.lastIndexOf("dos") != -1)
System.out.println("This is a MS-DOS terminal");
menu.clearCommand = "C:\\DOS\\cls";
try
menu.cls = Runtime.getRuntime().exec(menu.clearCommand);
menu.cls.waitFor();
menu.clsOut = new BufferedReader(new InputStreamReader(menu.cls.getInputStream()));
while (menu.clsOut.ready())
System.out.println(menu.clsOut.readLine());
menu.clsOut.close();
catch (Exception e)
-However, I also want to make sure that the system command is not an alias for a malicious script, in terms of invoking any sort of IO (delete/create files, etc.). Is it possible to have some sort of wrapper mechanism around the execution of the system command to detect and catch any attempt to perform IO? So far, my application works as the code speaks out, but I am worried that the system command may not be what I expect.
Thanks.
--AshwinWhat about making the information you need to clear the screen a part of the installation?
You do
clear >myclear.out
cls >myclear.out
or whatever and use the contents of the "clear screen" file from your Java program.
Caveat however: under Unix you can have different types of terminal with different clear-screen sequences.
Sometimes I ponder to make a request for a curses-like java package to give an API for such (more advanced, but still CUI-related) things. Or maybe there is such without my knowing it? -
Unzip file using operating system command in file/ftp receiver adapter
Hi,
I'm wonderdering how to unzip a zip-file in the receiver file/ftp adapter. I know it is possible to do it using the 'Operating system command' feature, but somehow the command I use seems to be ignored! (I'm using SP14, unix).
The command I entered is quite simple: unzip %F (also tried the %f, but i guess it doesn't really matter wich on I use).
Is it possible that I'm unzipping to another directory than the one i expect? the unzip should be performed to/in the current directory, and assumingly current directory is the one stated in the 'Target Directory', right?
Hope someone can clearify this issue for me.
Best regards,
DanielHi Daniel,
It seems to me also, that the files are being unzipped to a different location than what you are expecting. The OS command might getting executed in some default location(i am trying to fnd that out)on the server and not in the target directory of the channel(It seems logical to me)....
If you have time...pls try this out & see whether this would help...
Have a shell script written with the following commands in them
cd <path to target directory>
unzip $1(filename from the channel)
and in the OS command in the Channel give....
<absolute path to the .sh file> %F
Thanks,
Renjith. -
Run operating system command for sender File adpter (NFS)
Hi All,
iam doing a file to RFC scenario, using 'Run operating system command' in sender file adapter to change the file name while archiving (after processing completed).
I mention OS command like this:
sample_server\scripts\Test\Rename.bat"
Rename.bat file calls a 'perl script' code.
when i run interface, could see below statement in adapter log ->
"Execute OS command "
sample_server\scripts\Test\Rename.bat"
but the script was not run and file name was not changed.
Please advice what could be the problem?
Does this mean script executed successfully?
Do i need install perl software on XI server, even perl script (.bat file) is executing on sample_server?
Thanks in advance..
Regards,
RajeshHi,
Just check the following URL and give it a try again :-
Executing Unix shell script using Operating System Command in XI
Hope this info Helps..
Regards,
Aditya -
i am creating 2 files with file adaptors..
lest say a1.txt and a2.txt..
in the file adaptor i am specifying the path of a batch file which is located at the same location where these 2 files are created......this batch file should run after message processing
i am using this .bat file to create a file by combining these 2 files and delete these 2 files after that...
but nothing seems to be happening..after the 2 files are created.
seems like the command is not getting triggered which it is suppose to after message processing.
please helpHi Tarun,
Check this blog, Might give u some idea as well...
<a href="/people/michal.krawczyk2/blog/2007/02/08/xipi-command-line-sample-functions: Command line sample functions</a> By Michal Krawczyk
<a href="/people/sameer.shadab/blog/2005/09/21/executing-unix-shell-script-using-operating-system-command-in-xi Command - Executing Unix SHELL scripting</a> By Sameer Shadab
Regards
San
Where there is a <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/weblogs?blog=/weblogs/topic/16">blog</a> there is a Way. -
Executing Operating system commands in ABAP
Hi
I want to execute a unix operating system command in an ABAP program. I remember seeing code which executes an operating system command. Could any please let me know about that code?
Thank You.
EswarHi,
you can try something like this.
data:cmd(254) type c.
data: RESULT(255) OCCURS 100 WITH HEADER LINE.
cmd = 'ls'.
** Execute command
REFRESH RESULT.
CALL 'SYSTEM' ID 'COMMAND' FIELD CMD
ID 'TAB' FIELD RESULT-*SYS*.
Kostas -
I am new to JAVA Programming and I need help in coding. I need to run a system command using Java code. For example running a unix command like "service httpd status" and display it's result. Can anyone help?
Have a look at Runtime.exec()
http://java.sun.com/j2se/1.4/docs/api/java/lang/Runtime.html -
ABAP to FTP connect to non SAP UNIX system
Greetings~
I'm looking for a way (via function modules and/or BAPI) to transfer data in flat files from an SAP UNIX system to a non-SAP UNIX system using an ABAP program. I see FM's FTP_CONNECT and FTP_COMMAND however these seem to only work with UNIX systems running SAP as they require RFC_DESTINATION information. Anybody know which (if any) FM's can be used without the necessity of the target system running SAP/RFC?
Thanks!Hi Joseph,
Please refer the below program.
REPORT ZHR_T777A_FEED.
tables: t777a. "Building Addresses
Internal Table for Building table.
data: begin of it_t777a occurs 0,
build like t777a-build, "Building
stext like t777a-stext, "Object Name
cname like t777a-cname, "Address Supplement (c/o)
ort01 like t777a-ort01, "City
pstlz like t777a-pstlz, "Postal Code
regio like t777a-regio, "Region (State, Province, County)
end of it_t777a.
Internal Table for taking all fields of the above table in one line
separated by |(pipe).
data: begin of it_text occurs 0,
text(131),
end of it_text.
Constants: c_key type i value 26101957,
c_dest type rfcdes-rfcdest value 'SAPFTPA'.
data: g_dhdl type i, "Handle
g_dlen type i, "pass word length
g_dpwd(30). "For storing password
Selection Screen Starts
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE TEXT-001.
parameters: p_user(30) default 'XXXXXXX' obligatory,
p_pwd(30) default 'XXXXXXX' obligatory,
p_host(64) default 'XXX.XXX.XX.XXX' obligatory.
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE TEXT-002.
parameters: p_file like rlgrap-filename default 't777a_feed.txt'.
SELECTION-SCREEN END OF BLOCK blk2.
Password not visible.
at Selection-screen output.
loop at screen.
if screen-name = 'P_PWD'.
screen-invisible = '1'.
modify screen.
endif.
endloop.
g_dpwd = p_pwd.
Start of selection
start-of-selection.
To fetch the data records from the table T777A.
select build stext cname ort01 pstlz regio
from t777a
into table it_t777a.
Sort the internal table by build.
if not it_t777a[] is initial.
sort it_t777a by build.
endif.
Concatenate all the fields of above internal table records in one line
separated by |(pipe).
loop at it_t777a.
concatenate it_t777a-build it_t777a-stext it_t777a-cname
it_t777a-ort01 it_t777a-pstlz it_t777a-regio
into it_text-text separated by '|'.
append it_text.
clear it_text.
endloop.
To get the length of the password.
g_dlen = strlen( g_dpwd ).
Below Function module is used to Encrypt the Password.
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
SOURCE = g_dpwd "Actual password
SOURCELEN = g_dlen
KEY = c_key
IMPORTING
DESTINATION = g_dpwd. "Encyrpted Password
*Connects to the FTP Server as specified by user.
Call function 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
text = 'Connecting to FTP Server'.
Below function module is used to connect the FTP Server.
It Accepts only Encrypted Passwords.
This Function module will provide a handle to perform different
operations on the FTP Server via FTP Commands.
call function 'FTP_CONNECT'
EXPORTING
user = p_user
password = g_dpwd
host = p_host
rfc_destination = c_dest
IMPORTING
handle = g_dhdl
EXCEPTIONS
NOT_CONNECTED.
if sy-subrc ne 0.
format color col_negative.
write:/ 'Error in Connection'.
else.
write:/ 'FTP Connection is opened '.
endif.
**Transferring the data from internal table to FTP Server.
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
HANDLE = g_dhdl
FNAME = p_file
CHARACTER_MODE = 'X'
TABLES
TEXT = it_text
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
write:/ 'File has created on FTP Server'.
ENDIF.
Call function 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
text = 'File has created on FTP Server'.
To Disconnect the FTP Server.
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
HANDLE = g_dhdl.
To Disconnect the Destination.
CALL FUNCTION 'RFC_CONNECTION_CLOSE'
EXPORTING
destination = c_dest
EXCEPTIONS
others = 1.
Regards,
Kumar Bandanadham. -
Re: Error while Execute External Operating System Command using T.code SM49
Dear Experts,
I Have uploaded one .exe file in the application server (eg: sum.exe) and created the OS command in SM69 transaction .
And maintained the application server path in the 'operating system command' field in SM69 t.code.
Our SAP system, oprating system is UNIX.
After I have executed the external command using transaction SM49 , but I got the below error.
Can not execute external program (permission denied) , External program terminated with exit code 1
Immediately I run the SU53 transaction code to check the authorization, but Authorization was successful.
Could any one please help on this error.
Thanks in advance.>>Can not execute external program (permission denied) , External program terminated with exit code 1
You need to give the permission as 755 to your file.
>>I Have uploaded one .exe file in the application server (eg: sum.exe)
You are on UNIX and do not expect to any result of .exe file as UNIX doesn't know about this.
Maybe you are looking for
-
Videos on a web page will no longer play when accessed via a 'home screen' bookmark
iPad 2, iPad Mini iOS 8 I have saved certain web pages as bookmarks 'to the home screen' but since the iOS update when I open these pages and try to play an embedded video that is hosted on the website itself (as opposed to a YouTube type one) the vi
-
Out of memory error in adobe migration tool
Hello, While migrating data from version cue server to DAM server adobe migration tool is showing out of memory error. Is there any way to increase memory size for migration tool. Thanks,
-
Getting Application server's Port number
Hi from where we can get the application server's port number. i have forgot the port number of my AS thanks
-
Line Setup date passed and still no BT Line
Hello, On monday 9th the BT Openworld engineer arrived, he said that he couldn't setup up the line, as they would need a surveyor to visit. He said they'd be in touch within a day or two, however its now 5 days since then and I've not had any conta
-
Certificate Authorities - JINIT 1.1.8.19
HI, We are intending to deploy our Forms application (at mutiple client intranets, and internet as ASP), and wish to automate the procedure of deploying and cerftifying JAR components, intergrating with the client machine. We have followed the most h