How to execute external command from SAP
Hi gurus,
i need to execute an external command from a Sap (rel ECC.5.0) to a server UNIX (no SAP); precisely i have to write a file into a directory in unix server.
I see transaction SM49 and Sm69 but i don't know how can i use these features.
Please coul'd you help me or give me a documentation.
Thank's in advance
Maurizio Ortolani
email. [email protected]
Hi Maurizio,
i do it in this way:
CONSTANTS: CMD_LS(50) VALUE 'ls -al /transfer/sap'.
DATA: BEGIN OF ITAB_LS OCCURS 0,
LINE(200),
END OF ITAB_LS.
CALL 'SYSTEM'
ID 'COMMAND' FIELD CMD_LS
ID 'TAB' FIELD ITAB_LS-SYS.
How do you write the file, via an UNIX-COMMAND than try the above call
with your command.
Another way is to write the file via OPEN DATASET ..., TRANSFER ... TO ..., CLOSE DATASET.
If you mean this i can give you an example.
Hope it helps.
Regards, Dieter
Similar Messages
-
hi experts ,
i need to execute DOS command from SAP .
earlier we have 'GUI_EXEC' WS_EXECUTE , 'WS_DOWNLOAD' etc which are Obsolete now.
as we are using ECC6.0. kindly guide how to do this.
best regards,
RahulTry out...
DSVAS_DOC_WS_EXECUTE_50
or
CL_GUI_FRONTEND_SERVICES=>EXECUTE
<b><REMOVED BY MODERATOR></b>
Thanks & Regards
ilesh 24x7
Message was edited by:
Alvaro Tejada Galindo -
How to execute Linux command from Java app.
Hi all,
Could anyone show me how to execute Linux command from Java app. For example, I have the need to execute the "ls" command from my Java app (which is running on the Linux machine), how should I write the codes?
Thanks a lot,You can use "built-in" shell commands, you just need to invoke the shell and tell it to run the command. See the -c switch in the man page for your shell. But, "ls" isn't built-in anyays.
If you use exec, you will want to set the directory with the dir argument to exec, or add it to the command or cmdarray. See the API for the variants of java.lang.Runtime.exec(). (If you're invoking it repeatedly, you can most likely modify a cmdarray more efficiently than having exec() decompose your command).
You will also definitely want to save the returned Process and read the output from it (possibly stderr too and get an exit status). See API for java.lang.Process. Here's an example
java.io.BufferedReader br =
new java.io.BufferedReader(new java.io.InputStreamReader(
Runtime.getRuntime().exec ("/sbin/ifconfig ppp0").
getInputStream()));
while ((s = br.readLine()) != null) {... -
How to execute unix command from ODI Procedure
Hi,
I am trying to execute below unix command from ODI Procedure (Command on Target tab) but I am getting the error "java.io.IOException: Cannot run program "cd": error=2, No such file or directory" but when I try to execute the same command using OdiOSCommand, it is executing successfully. I don't want to use shell script to execute this command. Is there any specific syntax am I missing to execute this command from ODI procedure?
cd /project3/tmt/;ls *.dmp > dmplist.lst
Please help me on this...
Thanks
MTHi nahlikh,
Thank you for the reply.
I used below command in Procedure but still getting the same error as "java.io.IOException: Cannot run program "OdiOSCommand": error=2, No such file or directory".
OdiOSCommand "-COMMAND=cd /project3/tmt/;ls *.dmp > dmplist.lst"
as I mentioned earlier if I use the command cd /project3/tmt/;ls *.dmp > dmplist.lst in OdiOSCommand tool it is executing successfully without any issues.
any thoughts appreciated to get a solution for this issue.
Thanks
MT -
How to execute external command?
How to execute follow command and get its ouput on linux ?
$ grep processor /proc/cpuinfo | wc -lsabre150 wrote:
nitelia wrote:
String[] command = {"sh","-c","grep processor /proc/cpuinfo | wc -l"};
Process pro = Runtime.getRuntime().exec(command);
BufferedReader bf = new BufferedReader(new InputStreamReader(pro
.getInputStream()));
String x = null;
while ((x = bf.readLine()) != null) {
System.out.println(x);
This should workWow! So all one has to do is to use a shell to run the command! Isn't it a pity I did not give this solution in reply #3?You old sabre rattler! ;-) -
How does execute PHP Script from SAP?
I've already installed SAPRFC and run SAP Function from PHP successfully. But failed when tried execute PHP script from SAP (SM59). Anyone can help me for a clear instruction for this problem?
ThanksHi Max,
here is the Source:
[code]
#!/usr/bin/php -q
<?php
// SAPRFC - Server example
// PHP server function RFC_READ_REPORT
// Require: CGI version PHP, RFC destination defined in SAP R/3 (SM59)
// http://saprfc.sourceforge.net
// Interface definiton for RFC_READ_REPORT
// (generated by saprfc.php - option Generate PHP)
$DEF_RFC_READ_REPORT = array (
array (
"name"=>"SYSTEM",
"type"=>"EXPORT",
"optional"=>"0",
"def"=> array (
array ("name"=>"","abap"=>"C","len"=>8,"dec"=>0)
array (
"name"=>"TRDIR",
"type"=>"EXPORT",
"optional"=>"0",
"def"=> array (
array ("name"=>"NAME","abap"=>"C","len"=>40,"dec"=>0),
array ("name"=>"SQLX","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"EDTX","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"VARCL","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"DBAPL","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"DBNA","abap"=>"C","len"=>2,"dec"=>0),
array ("name"=>"CLAS","abap"=>"C","len"=>4,"dec"=>0),
array ("name"=>"TYPE","abap"=>"C","len"=>3,"dec"=>0),
array ("name"=>"OCCURS","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"SUBC","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"APPL","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"SECU","abap"=>"C","len"=>8,"dec"=>0),
array ("name"=>"CNAM","abap"=>"C","len"=>12,"dec"=>0),
array ("name"=>"CDAT","abap"=>"D","len"=>8,"dec"=>0),
array ("name"=>"UNAM","abap"=>"C","len"=>12,"dec"=>0),
array ("name"=>"UDAT","abap"=>"D","len"=>8,"dec"=>0),
array ("name"=>"VERN","abap"=>"C","len"=>6,"dec"=>0),
array ("name"=>"LEVL","abap"=>"C","len"=>4,"dec"=>0),
array ("name"=>"RSTAT","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"RMAND","abap"=>"C","len"=>3,"dec"=>0),
array ("name"=>"RLOAD","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"FIXPT","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"SSET","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"SDATE","abap"=>"D","len"=>8,"dec"=>0),
array ("name"=>"STIME","abap"=>"C","len"=>6,"dec"=>0),
array ("name"=>"IDATE","abap"=>"D","len"=>8,"dec"=>0),
array ("name"=>"ITIME","abap"=>"C","len"=>6,"dec"=>0),
array ("name"=>"LDBNAME","abap"=>"C","len"=>20,"dec"=>0)
array (
"name"=>"PROGRAM",
"type"=>"IMPORT",
"optional"=>"0",
"def"=> array (
array ("name"=>"","abap"=>"C","len"=>40,"dec"=>0)
array (
"name"=>"QTAB",
"type"=>"TABLE",
"optional"=>"0",
"def"=> array (
array ("name"=>"LINE","abap"=>"C","len"=>72,"dec"=>0)
// Create list of PHP server functions
$GLOBAL_FCE_LIST[RFC_READ_REPORT] = saprfc_function_define(0,"RFC_READ_REPORT",$DEF_RFC_READ_REPORT);
// PHP server function
function RFC_READ_REPORT ($fce)
$REPORT = saprfc_server_import ($fce,"PROGRAM");
saprfc_table_init ($fce,"QTAB");
$fd = fopen ($REPORT,"r");
if (!$fd)
return ("NOTFOUND"); // raise exception "NOTFOUND"
while (!feof($fd))
$LINE = fgets ($fd,73);
saprfc_table_append ($fce,"QTAB",array("LINE"=>$LINE));
fclose ($fd);
saprfc_server_export ($fce,"SYSTEM","PHP");
return (true);
// Call script with: ./server.php -a phpgw -g hostname -x sapgw00
$rfc = saprfc_server_accept ($argv);
// Dispatch one function call
$rc = saprfc_server_dispatch ($rfc,$GLOBAL_FCE_LIST);
saprfc_close ($rfc);
?>
[/code]
Regards
Gregor
Message was edited by: Gregor Wolf -
How to executing serial commands from text document
I'm looking for some direction on how to read and execute a page of serial commands from a text file. I have an instrument is controlled by serial communication. Currently I have been using a state machine to operate the instrument. The issue is that if I wish to change the sequence of commands I have to go back and rewrite the state machine to change the strings. I had the idea of being able to just write the string commands to a text file with each line being a discrete command and after selecting the file the VI would execute the text page one line at a time. I just don't know where to start and have been unable to find an example to get me started. This is above my programming level and I could use some direction on where to start. The one issue I need to be able to address is if the VI executing the page of serial commands I have to have a way to abort the sequence if necessary.
Thank you
Danny
DannyABCPrograms wrote:
If you want to process the entire array of commands in a state engine, indeed the better way of keeping track of where you are in the array would be a shift register.
When you're reading a new line, increase the index with one and put the new index in the shift register.
That seems overly complicated, unless you want to go back and repeat steps. But from the description from the OP, this is not desired. The point of the text document is to easily change the state order. Autoindexing is by far the simplest way to accomplish this. If you really want to know what index you are on, just use the i terminal.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines -
How to execute Excel Marco from SAP using Office Integration Classes
Is there a way to trigger Excel Macro from SAP? I tried using method CALL METHOD document->execute_macro
of i_oi_document_proxy but it does not work.
Thanks
VivekTry this:
If you are using OLE to populate the Excel Sheet then, then yes you can run a macro.
CALL METHOD OF OBJ_EX_APP 'Run'
EXPORTING #1 = MACROSTR.
Adding a Field Exit
To add a field exit first find the data element that is linked to the screen field- the screen number and program
Run program RSMODPRF. You will need to create two function modules one FIELD_EXIT_MEPO_VENDOR and
FIELD_EXIT_MEPO_VENDOR_A
FIELD_EXIT_MEPO_VENDOR should have code simply of input = ouput.
FIELD_EXIT_MEPO_VENDOR_A should have the code for whatever the functionality is required
Go back to RSMODPRF and run the program without parameters. Use the push buttons to assign the screen, 'A' and program. Use the drop down to activate the field list.
This should now work, but there is no way of debugging. For further information look at OSS 29377
program zzdirlist.
for AIX this method also works.
DATA: BEGIN OF TABL OCCURS 0,
TEXT(80) TYPE C,
END OF TABL.
DATA: COMMAND(256) TYPE C.
COMMAND = 'ls'.
CALL FUNCTION 'RFC_REMOTE_PIPE' DESTINATION 'SERVER_EXEC'
EXPORTING COMMAND = COMMAND
READ = 'X'
TABLES PIPEDATA = TABL.
LOOP AT TABL.
WRITE:/ TABL-text.
ENDLOOP. -
How to execute system command from java program
Hi all,
I want to change directory path and then execute bash and other unix commands from a java program. When I execute them separately, it's working. Even in different try-catch block it's working but when I try to incorporate both of them in same try-catch block, I am not able to execute the commands. The change directory command works but it won't show me the effects of the bash and other commands.
Suggestions??The code I am using is....
try
String str="cd D:\\Test";
Process p=Runtime.getRuntime().exec("cmd /c cd
"+str);your str string is already having cd in it but again you ar giving cd as part of this command also please check this,i will suggest you to remove cd from str
Process p1=Runtime.getRuntime().exec("cmd /c mkdir
"+str+"\\test_folder");you should say mkdir once you change your path,but here you are saying mkdir first and then cd D:\Test(this is because of str)..please check this
Process p2=Runtime.getRuntime().exec("cmd /c bash");
Process p3=Runtime.getRuntime().exec("cmd /c echo
himanshu>name.txt");
catch(IOException e)
System.err.println("Error on exec() method");
e.printStackTrace();
Message was edited by:
ragas -
How to execute os command from ABAP program?
I want to execute some window commands from ABAP. What is the way to do it?
Hi,
See ht e coding below, I have used these Fm to connect to FTP server and get the Files..
*types for the ftp command result internal table
TYPES : BEGIN OF ty_result,
text TYPE char512,
END OF ty_result.
data it_result type standard table of ty_result.
*Connect to the FTP server
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = lv_user " user name pass word to connect
password = l_v_pwd
host = 'dev.eu.pm.com' " Host name here
rfc_destination = 'SAPFTPA' "destination name
*Ask your functional people for the above data
IMPORTING
handle = v_handle
EXCEPTIONS
not_connected = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
*Changing directory
CONCATENATE 'cd' '<file path>' INTO l_v_cmd SEPARATED BY space.
you can also ser 'DIR in l_v_cmd which opens the directory and all the folders *get into it_result table..
*Execute the FTP Command
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = v_handle
command = l_v_cmd
TABLES
data = it_result
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
ENDIF.
rewards if useful,
regards,
nazeer -
How to execute unix command from the Java program running on Windows
Hello,
I need to
1. Execute a unix shell script from a Java program running on the Windows.
2. I also need to capture the output of this shell script in my program.
Please suggest me how to achieve this.
Thanks in Advance.Hi...
Something is missing here
If you want to execute a shell script in windows that not posible unless you find or develop a unix shell script parser for windows.
But if you are trying the execute a unix shell script on a remote unix computer from your java program running on a windows platform you can do that by logging on to the UNIX terminal which is running on port 23 I think.
You can test this using telnet tool on windows
just type on command prompt
telnet <ip of the unix pc> <port number this case 23>
you should get the unix terminal. If that works you can do the same through java or you can directly conect to port 23 of that pc using sockets that way your program will be platform independant -
hi friends,Iam used mysqldump command in linux platform to take backup of the database,its work properly....the command am used is
mysqldump -u root -p threadpool > sampledatabase.sql
I need to execute the same command in java....?Anyone here to know how to do that....?Thanks in advance........Crosspost:
http://forum.java.sun.com/thread.jspa?threadID=5185230&messageID=9721722#9721722
http://forum.java.sun.com/thread.jspa?threadID=5185199&messageID=9721587#9721587
Do not mess the forum. -
Execute shell command from Java
Hi all,
I need some idea for executing shell script from Java programe.
For example i have start.sh script in /tmp/start.sh folder of unix server.
I want to execute shell script from local java code.
Any idea on this.Hi,
Read the following articles/posts, maybe this could help you:
How to execute shell command from Java
Running system commands in Java applications | java exec example | alvinalexander.com
Want to invoke a linux shell command from Java - Stack Overflow -
Executing external command and program in background
Hi,
how to execute external command and external program in background.
please provide me some tips on the same.
while creating external command, what is the significance of "operating system command" and "parameters for operating system command".
Thanks,
Dinesh.Hi,
You can define external commands using transaction code SM69.
External commands are commands which would be executed at your operating
system with or without parameters.
Operating system commands are those which you execute at OS level like
mkdir, cat, rm, cp, ls
Parameters are options that you add to os commands to get more functionalities.
like, < ls -l > : will give you a long listing of files where " l " is the parameter
< ls -lt > : will give you a long listing with last changed file at top where " lt " is the parameter.
You can mention these in SM69 when you define the external commands.
Now, in order to execute these in your background job. In the steps click on "external command" and give your command name in SM36 while creating your job.
" Points for solution ".
Thanks and Regards,
Sandeep. -
How to execute external exe in SSIS Package
Hi,
I wanted to know how to execute external exe from SSIS Package can any one explain me or provide me valuable links.
Regards ,
AjayThere are few things you need to take care before executing exe from SSIS
1. The arguments etc expected by exe should be clearly defined inside execute process task
2. The Path where exe exists should be accessible to the account executing the package. SO you should grant account required permissions
3. If executing from a job make sure you either define a proxy account with required permissions and configure it to run the job or give service account all access required for executing exe
see
http://www.mssqltips.com/sqlservertip/2163/running-a-ssis-package-from-sql-server-agent-using-a-proxy-account/
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page
Maybe you are looking for
-
How to avoid reloading prototype icon when string paramater in C/C++ adapter?
I have a function in my C++ DLL. static BOOL InitializeConnection(unsigned char* receivedData, unsigned int* receivedDataLength, unsigned int* errorCode, unsigned char errorMessage[512
-
When I have finished working on an image in Photoshop and I hit the "save" button, it goes instead to the "save as" screen. This never happened in previous Photoshop versions. When I get to Lightroom, I have a grey screen the says "File could not be
-
I entered wrong password on my ipod touch too many times and now the screen is disabled. How do I get back into it?
-
TS1702 Getting billed for apps that i never recieved
I tried to purchase an app and got billed twice, but the app install gave an error to do with my account even thou the cash was deducted twice.... and no app to show for it... what do i do? the app was whats app.
-
How to make 3 iphones seperate accounts
I have 3 iphones on my account so that everything each of us has gets blasted onto others when upgraded. How do I get the other 2 off my account how do they develope their own accounts? Now my sons text are going to my husbands phone after he upgrad