Excuting unix program.
Hi.
I just want excute java.exe in bw unix without using function 'SXPG_CALL_SYSTEM'.
cause that function has limit number of command string.
I think I can use this command but somehow it returns null.
don't know what is problem and actually not sure usage of CALL 'SYSTEM' function.
anyone can fix this problem?
DATA: INFO_SGL(700) TYPE C OCCURS 0 WITH HEADER LINE.
data: COMMAND_STR type string.
data: CODE_number_500 type string.
CODE_number_500 = '43423424324........'.
concatenate '/opt/java1.3/bin/java -jar'
' test_v2.jar'
CODE_number_500
INTO COMMAND_STR.
CALL 'SYSTEM' ID 'COMMAND' FIELD COMMAND_STR ID 'TAB' FIELD INFO_SGL-SYS.
loop at info_sgl.
return_value = info_sgl.
endloop.
thank you.
Hi,
Length of the parameter COMMANDNAME is 18.
Hence 'CODE_number_500' should work.
There must be some other problem.
Go thru following documentation.
Hope it helps.
FU SXPG_CALL_SYSTEM
Execute an External Command
Functionality
SXPG_CALL_SYSTEM: Execute External Command (Express Method)
Using this function module, you can:
o Check a user's authorization to execute a command
o Execute the command
To determine the system on which the command should be executed, the
function module uses by default the current host system and the current
operating system type of the user.
As the function module is RFC-capable, you can use the RFC interface
(Remote Function Call Interface) to run the function module in a
different SAP application server. The external command is then
accordingly executed in the host system of the other SAP server.
SXPG_CALL_SYSTEM uses the following rules to determine which variant of
a command is used for the execution:
o If a command with the same operating system type as the one in the
sytem field SY-OPSYS exists, this definition is used for the
execution of the command.
o If the first check fails, the syntax group for SY-OPSYS is
determined. A syntax group is an SAP construct that groups operating
systems that use the same syntax for commands and filenames. If a
command whose operating system type matches the determined syntax
group, this definition of the command is used.
o If no matching definition is found for the syntax group, the
function module searches for a definition with the operating system
type ANYOS (executable in all supported operating systems). This
definition is then used, if found.
o Otherwise, the exception COMMAND_NOT_FOUND is triggered.
Use
Syntax:
CALL FUNCTION SXPG_CALL_SYSTEM
IMPORTING
COMMANDNAME = <SAP command name> DEFAULT '*'
ADDITIONAL_PARAMETERS = <Argument string> default <space>
EXPORTING
STATUS = <Exit status of command>
TABLES
EXEC_PROTOCOL = <Log> In structure BTCXPM. Can
contain STDOUT, STDERR
EXCEPTIONS
NO_PERMISSION Command rejected by User exit auth.
check
COMMAND_NOT_FOUND Command not defined in SAP database
PARAMETERS_TOO_LONG Complete parameter string exceeds
128 characters
SECURITY_RISK Security check failed
WRONG_CHECK_CALL_INTERFACE Problem with function
module for additional security
check
PROGRAM_START_ERROR Error while starting program
PROGRAM_TERMINATION_ERROR Error while requesting final
status of program
X_ERROR Reserved
PARAMETER_EXPECTED Required parameter not specified
TOO_MANY_PARAMETERS User arguments not allowed by
supplied in call
ILLEGAL_COMMAND Command not legitimately defined
OTHERS
Parameters
COMMANDNAME
ADDITIONAL_PARAMETERS
STATUS
EXITCODE
EXEC_PROTOCOL
Exceptions
NO_PERMISSION
COMMAND_NOT_FOUND
PARAMETERS_TOO_LONG
SECURITY_RISK
WRONG_CHECK_CALL_INTERFACE
PROGRAM_START_ERROR
PROGRAM_TERMINATION_ERROR
X_ERROR
PARAMETER_EXPECTED
TOO_MANY_PARAMETERS
ILLEGAL_COMMAND
Function Group
SXPT
Regards,
Shashank
Similar Messages
-
Unable to excute unix command from java program
import java.io.File; // is java code
public class RunSystemCommand {
public static void main(String args[]) {
String s = null;
// system command to run
String cmd = "ls ";
// set the working directory for the OS command processor
File workDir = new File("c:/cygwin/cygwin");
Process p = Runtime.getRuntime().exec(cmd, null, workDir);
p.waitFor();
I am tryiing to excute above code to run unix command on cygwin but gave folllowing error...... but works well to open a note pad..
Exception in thread "main" java.io.IOException: CreateProcess: C:/cygwin/bin err
or=5
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Unknown Source)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at d.main(d.java:19)
It seems using this functionone cannot excute unix commands..please help to do so..Are you sure you want cygwin/cygwin?
the following works fine for me, you may need change the workDir to your bin folder
import java.io.File; // is java code
import java.io.InputStream;
public class RunSystemCommand {
public static void main(String args[]) throws Throwable {
String s = null;
// system command to run
String cmd = "ls ";
// set the working directory for the OS command processor
File workDir = new File("c:/cygwin/bin");
Process p = Runtime.getRuntime().exec(cmd, null, workDir);
InputStream pis = p.getInputStream();
while( pis.read() != -1 ); // added, as otherwise the ls hangs.
p.waitFor();
} -
Trigger Unix Program from a stored procedure
Is it possible to start a Unix program as a background OS process from a stored procedure?
In fact I want to call a stored procedure which starts a Unix process. After the termination of this process get the results of the programm (a text file) using UTL_FILE package from the stored procedure and produce an HTML document based on the output of the started process using the htp package.
Thanks, JVwrote:roadbike
Whats the best way to start a host (Unix) program from a stored procedure or trigger without having to wait for a response from the program (i.e start it and forget it )The BEST way depends on your operating system and version of the Oracle database. If you are at Oracle 10g or higher, I would certainly suggest using dbms_scheduler. In 10gR2 you can set a program to execute on receipt of an event, and the trigger or stored procedure can be the cause of the event. -
Upgrade from macbook to macbook Pro: How to move UNIX programs?
I am thinking of upgrading from my intel macbook to a C2D macbook Pro. I know that I can use the migration assistant to move all my User files and Applications over to the new machine. But, is there a way to move all my installed UNIX programs, such as TeX and other libraries/programs that I installed with Fink?
If I just mirror the old drive to the new one, will that work? I'd like to have exactly the same setup on the new machine as the old one.
Thanks, JoshOk, so it is my understanding that the new C2D MBP's come with 10.4.8 build 8N1037. My 1st gen macbook has 10.4.8 build 8L2127. I read a blog by Jason D. O'Grady that describes moving from a 1st gen MBP to a C2D MBP with the same OS build discrepancy. He states that by using the install disks from the new MBP to update the OS on the old MBP he can just swap the harddrives:
"Although the new MeBook ships with Mac OS 10.4.8 installed it is a different build (8N1037) than the build that is installed on my previous MBP (8L2127). For this reason you need to use the install DVDs that come with the MeBook and upgrade the OS on the donor HDD (still in the original MBP) before the swap. Allow about 30 minutes for this process and use the time to take apart the receiving MBP."
http://blogs.zdnet.com/Apple/?p=325
So, following this logic, can I do the following ?!? :
1. I buy a new MBP
2. Put the new install DVD into my old macbook and update the OS to the new build
3. Use SuperDuper (my backup program of choice) to mirror my old HD onto the new HD
4. Seamlessly update from the macbook to the MBP and live happily ever after
Thanks,
Josh -
To execute from ABAP code an external Unix program
HI,
I would like to know how to execute from ABAP code an external Unix program and check for a return code?HI,
There are different ways to this:
(1) OPEN DATASET <file> FOR OUTPUT 'unix command'
CLOSE DATASET <file>
This command executes the unix command and writes the output into <file>
Look into OSS Note 9391.
(2) or try the following program but unfortunately the command CALL SYSTEM is
not supported by SAP. If you are on R/3 2.1 - 2.2x you can get some idea's from the program SAPMSOS0.
REPORT ZUNIXCOM .
DATA: U_COMMAND(200).
Table for system messages
DATA: BEGIN OF RT OCCURS 100 ,
LINE(100) ,
END OF RT .
START-OF-SELECTION .
MOVE 'unix command' to U_COMMAND .
REFRESH RT.
CALL 'SYSTEM' ID 'COMMAND' FIELD U_COMMAND
ID 'TAB' FIELD RT-SYS .
LOOP AT RT.
WRITE : / RT-LINE .
ENDLOOP.
Reward Points if found helpfull..
Cheers,
Chandra Sekhar. -
Excute unix script from java.
Hi need to excute unix script from java application.
My code is:
public class Test
public static void main(String args[])
try{
p = Runtime.getRuntime().exec("./qfe0"); //qfe0 is the name of the script.
p.waitFor();
catch(Exception e)
e.printStackTrace();
My problem is that using the waitFor() statement stuck the the script. if i don't use the waitFor() it works good but then i don't know when the script is finished.
Any idea?The problem is likely to be that you script is either waiting for input or has filled the stdout buffer and you are not emptying it. Search this forum for this as its been answered many times before.
-
I need to from my java program to run a unix program, and then use the resulting output from that program in my program. How is this done?
Have a look at the java.lang.Runtime class: http://java.sun.com/j2se/1.4/docs/api/java/lang/Runtime.html You can get the output from the Process that is returned from the exec methods.
-
Using Forms as Interface for Unix Program
I am trying to develope an interface for a unix program that demands input from the database. Is it possible to do that? How can I initiate the Unix program from within Forms?
Thankshi,
have a look to the HOST build-in-function ;-)
e.g. HOST('myprog para1 para2');
Regrads
biki -
How to Redirect a Unix program to output to Java not a log
Hi all!
Okay, here is what I am trying and I cannot seem to get a handle on where I should start.
I have a Unix program that basically outputs to a log file when a error occurs. (std_err_file: /Errorfile)
What I am trying to do is have this entry redirected to a java program that will take the log stream and then use it in some fashion. Perhaps (std_err_file: >java readlog Errorfile)? Not sure if this will work, and I need to get a better understanding of what type of stream to use to read this data.
Can anyone give me a pointer in the "write" direction??
Thanks in advance...Just read it in like you would keyboard input.
Programs have three IO streams permanently attached
Standard In (stdin) is an Input Stream.
Standard Out (stdout) is an Output Stream.
Standard Error (stderr) is a Second Output Stream.
Think of it this way:
Each STDxxx is like a hose. When you invoke a program, by default the
hoses are attached as follows:
stdin is attached to the keyboard for input.
stdout is attached to the console window for output.
stderr is attached to the console window for output.
In java, the streams System.in, System.out, System.err are the other ends of these hoses.
Now, in Unix (and similarly in dos or NTshell) you can connect these hoses in different ways using a "pipe" (hence the hose metaphor)
'Program1 | Program2' will take the stdout stream from Program1, and disconnect it from the console window. It will also disconnect the stdin stream from the keyboard, and then, it will slip in a piece of pipe between the two hoses, thus connecting them.
So, program2 can read the output on its System.in stream in exactly the same way as it would if it was connected to the keyboard. In fact, Program2 has absolutely no knowledge of what is at the other end of that hose, just that there is data coming down it.
So, the leaves us with the question "What is stderr for?" It's for error messages. It is often convenient to use a pipe or a file redirect (similar to a pipe) to send data to a file, but errors to the screen.
A programmer can facilite this by sending all true output to System.out, and all error messages to System.err
Example: (in class Bob)
System.out.println("Hello Bob");
System.err.println("Warning: Bob is hacking again.");
java Bob | someProgram
// pipe the stdout of Bob to someProgram
// leave stderr attached to the keyboard.
Will send the message Hello Bob to someProgram, but the Error message will appear on the console for the system administrator to read.
Do a google on "Pipes and redirects" for more info. -
How to excute a program written in other language?
How to pass some parameters to other excutable program written in other languages and to get the return value back?
http://java.sun.com/j2se/1.3/docs/api/java/lang/Runtime.html
-
How to call a unix program which is IRIX OS from java
Hi,
I have a program on UNIX platform and OS is IRIX. I have a java program on WINDOWS machine. I want to run that program, which is on UNIX paltform from java. I know the path but I am not able to give that path using Runtime.exec() command.I can run any file on the WINDOWS machine using my JAVA program. Can anybody help me ???I am not really sure if I understood your problem, but it might have something to do with forgetting to set the LD_LIBRARY_PATH.
Set this path according to your needed paths and maybe this already solved your problems.
Greetings,
John -
Excute Unix command Using PL SQL
Greeting,
how can I execute shell unix commands from PL SQL and without passing by the Java virtual machine, because my database server is not very performant to support the heaviness of Java.
Thank you for ur help!!!Is this what you need ?
TEST@db102 SQL> create table test(dir varchar2(100), url varchar2(200));
Table created.
TEST@db102 SQL> insert into test values('/tmp','http://otn.oracle.com');
1 row created.
TEST@db102 SQL> commit;
Commit complete.
TEST@db102 SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[ora102 work db102]$ cat /tmp/wget.sh
#!/bin/bash
rm -f /tmp/index.html
/usr/bin/wget -P $1 $2
[ora102 work db102]$ sqlplus test/test
SQL*Plus: Release 10.2.0.1.0 - Production on Sat Jul 29 17:11:28 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
TEST@db102 SQL> DECLARE
2 v_dir varchar2(100);
3 v_url varchar2(200);
4 BEGIN
5 select dir, url into v_dir, v_url
6 from test;
7 DBMS_SCHEDULER.CREATE_JOB(
8 job_name=>'testjob',
9 job_type=>'EXECUTABLE',
10 job_action=>'/tmp/wget.sh',
11 number_of_arguments => 2,
12 enabled => FALSE);
13 dbms_scheduler.set_job_argument_value('testjob',1,v_dir);
14 dbms_scheduler.set_job_argument_value('testjob',2,v_url);
15 dbms_scheduler.enable('testjob');
16* end;
TEST@db102 SQL> /
PL/SQL procedure successfully completed.
TEST@db102 SQL>sorry for lost indentations, but tags do not help us these days.... -
How to get ALV saved vairant while excuting the program .
Hi all,
The program will display in the ALV format.suppose if i save that it will save in the variants .
The requirement is needs to taht variant in the selection screen.
How do we get that,Could you please help out.
Thanks
Sriman.Hello,
DO like this.
DATA : g_r_disp_variant TYPE disvariant.
SELECTION-SCREEN BEGIN OF BLOCK variant WITH FRAME TITLE text-003.
PARAMETERS: p_varian LIKE disvariant-variant DEFAULT '/STANDARD'.
SELECTION-SCREEN END OF BLOCK variant.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varian.
PERFORM show_existing_display_variants.
*& Form SHOW_EXISTING_DISPLAY_VARIANTS
* text
* --> p1 text
* <-- p2 text
FORM show_existing_display_variants.
g_r_disp_variant-report = sy-repid.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = g_r_disp_variant
i_save = 'A'
IMPORTING
es_variant = g_r_disp_variant
EXCEPTIONS
not_found = 1
program_error = 2
OTHERS = 3.
IF sy-subrc = 0.
p_varian = g_r_disp_variant-variant.
ENDIF.
ENDFORM. " SHOW_EXISTING_DISPLAY_VARIANTS
*form get_output
g_repid = sy-repid.
* display variant
g_r_disp_variant-report = sy-repid.
IF NOT p_varian IS INITIAL.
g_r_disp_variant-variant = p_varian.
ENDIF.
*get_output
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_grid_title = 'PRICE COMPARISON REPORT:'
is_layout = it_layout
it_fieldcat = it_fldcat
is_variant = g_r_disp_variant
i_default = 'X'
i_save = 'A'
TABLES
t_outtab = g_t_itab_alv
EXCEPTIONS
program_error = 1
OTHERS = 2.
Vasanth -
Want excute the program accourding to the radio buttons
hello,
i am writing an extraction program. here i want to get the out put file in diffrent formats based on the selection on myselection screen.
if
I seclect the radio button "EXCEL" the output should be excel file.
else
if
I select the radio button "DAT" the output should be DAT file.
Thanks,
vineetha.Hi Vineetha,
Check this program..
PARAMETERS:p_vbeln LIKE vbrp-vbeln.
Parameters:EXCEL radiobutton group GP1.
Parameters:TEXT radiobutton group GP1.
DATA:BEGIN OF it_vbrp OCCURS 0,
vbeln LIKE vbrp-vbeln,
posnr LIKE vbrp-posnr,
meins LIKE vbrp-meins,
ntgew LIKE vbrp-ntgew,
END OF it_vbrp.
START-OF-SELECTION.
SELECT vbeln
posnr
meins
ntgew FROM vbrp INTO TABLE it_vbrp where vbeln eq p_vbeln.
if EXCEL = 'X'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME ='C:\Documents and Settings\Vishnu.Chintala\reddy.xls'
TABLES
DATA_TAB = IT_VBRP
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Endif.
If TEXT = 'X'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME ='C:\Documents and Settings\Vishnu.Chintala\reddy2.TXT'
TABLES
DATA_TAB = IT_VBRP
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endif. -
WRITEQUERY to be excuted in program and filling Variable values
Hi SDN Community,
Is it possible to execute the WRITEQUERY FM, within ABAP,
And at the same time have the variables in the query populated. ie. do not force the variable screen to popup and fill it in.
Can you please provide a simple example if this is possible.
Thank you.
SimonThank You Praveen.
These look very useful, i will shortly be testing them.
You may be able to answer the following questions:
1) The output of those BLOGS is XML. would it be possible to simply put the contents in a table directly.
Do you think it would also be possible to do the following:
1) Create a function module that calls ZWRITEQUERY
(ZWRITEQUERY is a copy of the original code)
If we could then pass the genuid to this code via the input paramater to be set up in our FM.
to uncomment any code that displays the variable screen.
To then allow the code to execute
I would also like to try to find the code where there variables can be passed.
But then i think the above is quite complicated.
Thank you.
Simon
Maybe you are looking for
-
Good morning, does anyboby know if and how is possible planning costs on sales orders? Currently, sales orders are set as account assignment; actual costs are accounted without problems on sales orders and report KKBC_KUN properly shows costs. But no
-
The names of tags imported into Elements 11 from 4 show on the right of the screen. However they only show the taggged files when I click on one when I am in the Albums view on the left of the screen not when I am in the folder view? Am very new to
-
I just got an ipad mini and didf all the settings necessary. Went to turn on ipad this morning and apple icon shows then itunes icon and a long looking lock. I cannot get on ipad. Not sure how to get it opened and operational?
-
Can't see and open a pdf in a mail with ipad
I there, working with ipad2 can't understand , got sometimes pictures of my house from an architecte . these're send as pdf often I can't see the attachement and so impossible to see anything ! BUT when opening the mail on a Mac OS everything is ok
-
How does one link a moto x phone to a mac
how does one link a moto x phone to an I Mac?