How to execute a external command ?

Hi all ,
        I would like to transfer the oracle data to sql2000 , my idea is :
           - 1. write a external java program ( call trans.jar ) on oracle db server machine ( call sql2000 server to invoke the dtsrun.exe )
           - 2. create a dts package on sql2000 server .
           - 3. write an abap program in sap ( when the end-user execute this program , the trans.jar will call the dts package on sql2000 server ) .
        I know that we can use sm69 to define the external program , but i don't know how to use abap/4 to invoke this external program ? has someone can tell me how to do ?
Thanks a lot !
Best Regards,
Carlos

You can use the function module <b>SXPG_COMMAND_EXECUTE</b> to execute external commands
Please find my sample code for it.
*&      Form  TRIGGER_EXT_OS_COMMAND
*       text
*      -->P_F_UNIX  text
form TRIGGER_EXT_OS_COMMAND using P_F_UNIX type SXPGCOLIST-PARAMETERS.
  data: begin of IEPCOL occurs 100.
          include structure BTCXPM.
  data: end of IEPCOL.
BTCXPM = Log message from external program to calling program
  data: W_STATUS like EXTCMDEXEX-STATUS.
* EXTCMDEXEX = Parameters of SXPG_COMMAND_EXECUTE
  data: W_HOST like RFCDISPLAY-RFCHOST.
* RFCDISPLAY = Display structure for RFCDES maintenance          "M5
* The External operating system command ZECOM is created * using thetransaction SM69. For any changes to the
* command goto SM69 and for executing and testing use
* the transaction SM49.
  W_HOST = SY-HOST.
  call function 'SXPG_COMMAND_EXECUTE'
    exporting
      COMMANDNAME                   = 'ZECOM'
      ADDITIONAL_PARAMETERS         = P_F_UNIX
      OPERATINGSYSTEM               = SY-OPSYS
      TARGETSYSTEM                  = W_HOST
      STDOUT                        = 'X'
      STDERR                        = 'X'
      TERMINATIONWAIT               = 'X'
    importing
      STATUS                        = W_STATUS
    tables
      EXEC_PROTOCOL                 = IEPCOL
    exceptions
      NO_PERMISSION                 = 1
      COMMAND_NOT_FOUND             = 2
      PARAMETERS_TOO_LONG           = 3
      SECURITY_RISK                 = 4
      WRONG_CHECK_CALL_INTERFACE    = 5
      PROGRAM_START_ERROR           = 6
      PROGRAM_TERMINATION_ERROR     = 7
      X_ERROR                       = 8
      PARAMETER_EXPECTED            = 9
      TOO_MANY_PARAMETERS           = 10
      ILLEGAL_COMMAND               = 11
      WRONG_ASYNCHRONOUS_PARAMETERS = 12
      CANT_ENQ_TBTCO_ENTRY          = 13
      JOBCOUNT_GENERATION_ERROR     = 14
      others                        = 15.
  if SY-SUBRC <> 0.
    case SY-SUBRC.
      when 1.
        message E138(ZSM) with 'No permission to Execute ' 'External O/S command'.
      when 2.
        message E138(ZSM) with 'External O/S Command not found'.
      when 3.
        message E138(ZSM) with 'Parameters too long.' 'Exceeds the limit of 128 characters'.
      when 4.
        message E138(ZSM) with 'Security risk. ' 'The Command contains impermissible characters'.
      when 5.
        message E138(ZSM) with 'Wrong check call interface.  Check the command.'.
      when 6.
        message E138(ZSM) with 'Error while starting the External O/S Command'.
      when 7.
        message E138(ZSM) with 'Error getting the return ' 'code of the External O/S command'.
      when 8.
        message E138(ZSM) with 'Unknown error'.
      when 9.
        message E138(ZSM) with 'Some mandatory parameter is not supplied'.
      when 10.
        message E138(ZSM) with 'Too many parameters. ' 'Check the additional parameter'.
      when 11.
        message E138(ZSM) with 'Illegal command'.
      when others.
        message E138(ZSM) with 'Unknown error'.
    endcase.
  else.
    if W_STATUS = 'O'.
      if UNIX_FILE cs '.ES'.
        message S138(ZSM) with 'File FTP Successfull..!'.
*        External O/S command to' 'FTP the above file to' 'ES FTP server succesfully!' P_F_UNIX.
      endif.
    else.
      message I138(ZSM) with 'Ext O/S command to FTP the ' 'abv file to ext UNIX system not executed due to:'.
      loop at IEPCOL.
        write:/ SY-TABIX, IEPCOL-MESSAGE,255 ' '.
      endloop.
    endif.
  endif.
endform.                    " TRIGGER_EXT_OS_COMMAND
Regards
Gopi

Similar Messages

  • How to execute an external file in java ?

    How to execute an external file , where the file name of the external file is in unicode character. (i,e, may be in Chinese character).

    Process p = Runtime.getRuntime().exec("/path/to/executable");
    This is write. But my question is while the file name is in Chinese font.
    It means while a file name is in Chinese font or any unicode character that are supported by window but not in the command prompt. In this case the file name is changed to ??????.doc like.
    So, while trying to execute this it shows File not found message.

  • Execute an external command!

    how to i.e execute an external command with java and then get the output into a string variable?
    thanks in advance!
    .leonard

    Did you search this forum before posting this question?
    It is very rude to post a question to a forum that has been answered so many times and that is easily findable in the forum...
    Process p = Runtime.getRuntime().exec("your command");
    BufferedReader read = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line = null;
    while( (line = read.readLine()) != null)
      System.out.println("OUT>>>" + line);
    //

  • How to execute Operating System commands from Stored procedure.

    Any help on how to execute Operating System commands from stored procedures will be appreciated.
    Nanditha.

    Search the forums for 'External Procedure' and you will find example code that has been posted before.

  • How to execute a system command with call executable in teststand 4.2.1?

    Hi All,
          how to execute a system command with "call executable" step in teststand 4.2.1?
          example as i want to quit a application.using "taskkill /f /im xxx.exe".And execute other system command(DOS).
    BR
    Johnny

    Hi, 
    I want to run netstat -an | find "8080" command from command prompt using call executable in test stand. after that i would like take the std output to local variable. 
    Attachments:
    callsettings.jpg ‏404 KB

  • How to execute dir dos command in Runtime Execution

    Hi All,
    Does anybody know how to execute the dir command in DOS in the runtime execution
    for example,
    when we open the command prompt,
    c:\Documents and Settings\java> e:
    e:\cd java
    e:\dir *.*
    how we can list the directory in runtime execution?

    Process childProcess = Runtime.getRuntime().exec("cmd /C dir *.*");or try with
    ProcessBuilder pb = new ProcessBuilder("cmd /C dir *.*");
    Process childProcess = pb.start();
    NOTE: We can use the ProcessBuilder class from J2SE 5.0+.
    for further reference check the below link
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?page=3
    and don't forget to go through API documentation for java.lang package
    http://java.sun.com/j2se/1.5.0/docs/api/java/lang/package-summary.html
    and if you want to implement it through Java which provides you a list of Files & directories in the present directory here is an example of such code snippet REF:as insisted by my fellow poster.
    File file = new File("<present_directory_path>");
    if(file.isDirectory()){
       String fileNames[] = file.list();
            for(String fileName:fileNames)
               System.out.println(fileName);
      fileNames = null;
            or for detailed info use
             File files[] = file.listFiles();
             for(File fileEntity:files)
                System.out.println("FILENAME:"+fileEntity.getName+",IS FOLDER:"+fileEntity.isFolder()+",ABSOLUTE PATH:"+fileEntity.toString()+"FILE SIZE:"+fileEntity.length());
             files = null;
    }and please do not forget to go through File API Documentation provided as recommended by my fellow poster.
    hope this might help :)
    REGARDS,
    RaHuL

  • How to execute a shell command in java?

    here, my environment is redhat 7, jdk 1.5.
    i don't know how to use the shell command in java.
    i want to use this function:
    #include <stdlib.h>
    int system(const char * string);
    please give me some ideas. and Thank you so much if coming with a little demo.

    i know i should use JNI. because i have to use C lib.
    but i have already use JNI to wrapper the original code the cpp code and java code is :
    //: appendixb:UseObjImpl.cpp
    //# Tested with VC++ & BC++. Include path must
    //# be adjusted to find the JNI headers. See
    //# the makefile for this chapter (in the
    //# downloadable source code) for an example.
    #include <jni.h>
    #include <stdlib.h>
    extern "C" JNIEXPORT void JNICALL
    Java_UseObjects_changeObject(
    JNIEnv* env, jobject, jobject obj) {
    jclass cls = env->GetObjectClass(obj);
    jfieldID fid = env->GetFieldID(
    cls, "aValue", "I");
    jmethodID mid = env->GetMethodID(
    cls, "divByTwo", "()V");
    int value = env->GetIntField(obj, fid);
    printf("Native: %d\n", value);
    env->SetIntField(obj, fid, 6);
    env->CallVoidMethod(obj, mid);
    value = env->GetIntField(obj, fid);
    system("preprocess -path sha.c");
    printf("Native: %d\n", value);
    } ///:~
    //: appendixb:UseObjects.java
    // From 'Thinking in Java, 2nd ed.' by Bruce Eckel
    // www.BruceEckel.com. See copyright notice in CopyRight.txt.
    class MyJavaClass {
    public int aValue;
    public void divByTwo() { aValue /= 2; }
    public class UseObjects {
    private native void
    changeObject(MyJavaClass obj);
    static {
    // System.loadLibrary("UseObjImpl");
    // Linux hack, if you can't get your library
    // path set in your environment:
    System.load(
    "/root/jproj/UseObjImpl.so");
    public static void main(String[] args) {
    UseObjects app = new UseObjects();
    MyJavaClass anObj = new MyJavaClass();
    anObj.aValue = 2;
    app.changeObject(anObj);
    System.out.println("Java: " + anObj.aValue);
    } ///:~
    i modify this two file which is from TIJ-2edition.
    the output is
    Native: 2
    Native: 3
    Java: 3
    but what i want to be executed "preprocess -path sha.c" does not work.
    i have change the command to, such as "df", "ls" etc. but none of them works
    please help me.

  • How to execute a Unix Command in java

    Hi, Iam trying to execute a unix command on Sun Solaris by passing that command to a java program. How can I achieve this?
    Thanks in advance.

    Have a look at the javadoc around the Runtime.exec() method. If the command is a shell command then you might have to execute a shell as well as the command.
    For example, if you wanted to run a unix command 'ls -l > output.txt' the you might have to pass the following string into the exec() method,
    "/bin/sh ls -l > output.txt'

  • How to execute a shell command?

    What class and method should I use to set an environment variable on a local system? And how do I execute a shell command in Java?
    Thanks!

    I don't know about setting environment variables from java, but I do know how to execute system commands (and from there you could modify environment variables).
    Use Runtime.getRuntime().exec()
    There are quite a few pitfalls with using this though...
    1. It's platform dependent
    2. Doing this creates a Process. If this process has output, you need to read this, otherwise the output buffer will overflow, and that would be bad... Input is not so bad (either supplying it or not ;)
    3. If you use Win for example, and want to do a "dir", there are complications, as there is no dir.exe file, and hence it can't be executed... Do a search for this topic, there's plenty on how to get around it.
    Anyway, there's plenty more info on Runtime.getRuntime().exec(), have a look around.
    Cheers,
    Radish21

  • How to execute any cmd command from java application?

    Hi all,
    How to execute or call any command of cmd from java application??
    Is there any method to do so??
    Or, is it possible to do it using Runtime.exec() ??? And if so, how to use it, please explain with ab example...
    I'll highly appreciate....
    Thank you.

    If google would be the best option, then I would not be on Sun's forums and I would not have asked experts like you, sir !! :-)
    Neway, I got the solution from PhHein !!
    Good link indeed..
    Cheers..

  • How to Execute Power Shell Command From Windows Application.

    Hi All Experts,
    I want to execute power shell commands from my windows application.
    Is it possible ?
    Please let me know your comments..
    Thanks.

    I have not tried this, but apprently it is easy as in the sample pasted below. please see this article for more details
    http://geekswithblogs.net/Norgean/archive/2012/09/19/running-powershell-from-within-sharepoint.aspx.
    Let me know how it goes...
    public string RunPowershell(string powershellText, SPWeb web, string param1, string param2) {
    // Powershell ~= RunspaceFactory - i.e. Create a powershell context
    var runspace = RunspaceFactory.CreateRunspace();
    var resultString = new StringBuilder();
    try
    // load the SharePoint snapin - Note: you cannot do this in the script itself (i.e. add-pssnapin etc does not work)
    PSSnapInException snapInError;
    runspace.RunspaceConfiguration.AddPSSnapIn("Microsoft.SharePoint.PowerShell", out snapInError);
    runspace.Open();
    // set a web variable.
    runspace.SessionStateProxy.SetVariable("webContext", web);
    // and some user defined parameters
    runspace.SessionStateProxy.SetVariable("param1", param1);
    runspace.SessionStateProxy.SetVariable("param2", param2);
    var pipeline = runspace.CreatePipeline();
    pipeline.Commands.AddScript(powershellText);
    // add a "return" variable
    pipeline.Commands.Add("Out-String");
    // execute!
    var results = pipeline.Invoke();
    // convert the script result into a single string
    foreach (PSObject obj in results)
    resultString.AppendLine(obj.ToString());
    finally
    // close the runspace
    runspace.Close();
    // consider logging the result. Or something.
    return resultString.ToString();
    Ok. We've written some code. Let us test it.
    var runner = new PowershellRunner();
    runner.RunPowershellScript(@"
    $web = Get-SPWeb 'http://server/web' # or $webContext
    $web.Title = $param1
    $web.Update()
    $web.Dispose()
    ", null, "New title", "not used");
    -Sangeetha

  • How to execute Linux OS command  from ODI

    We have installed Oracle data integrator on windows machine and want to execute linux OS command in a procedure or scenario from ODI .
    How could i do that ?
    I can see os command elements but they do not work, only windows commands work.There should be linux technology i think

    Obviously you can execute Unix OS commands only on Unix OS. Why do you expect Windows to understand it?
    The solution in your case would be executing your ODI scenarios with an Agent installed on Unix machine.
    Cheers

  • How to execute XML batch commands using SharePoint Web services or Client Object Model

    Hi,
    I have a requirement to execute some batch commands to update SharePoint View Style, how can i do it using SharePoint webservices or SharePoint Client Object model.
          I need to execute the following Batch command over a particular web.
    <Method ID="UpdateView">
      <SetVar Name="Cmd">UpdateView</SetVar>
      <SetList Scope="Request">{GUID of List}</SetList>
      <SetVar Name="View">{GUID of View}</SetVar>  
      <SetVar Name="ViewStyle">6</SetVar>
      <SetVar Name="RowLimit">100</SetVar>
      <SetVar Name="Paged">TRUE</SetVar>
    </Method>

    Hi
    I tried it already... But UpdateView Method in the Views.asmx and Lists.asmx, both are not supporting for updating the style of the view (like Boxed, Newsletter...).
    If you have any code sample which will do this job with any of the SharePoint web services, please share it..

  • How to execute a cvs command using System Call?

    hi all,
    how to execute a cvs login command using system call ?
    thanks,
    dam

    To anyone that reached this post and still dont have a hint, try this small sample - it logs on CVS using installed CVSNT and execute a fake update:
    package testeCVS;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.io.PrintWriter;
    public class execCMD
        String password="yourPassword";
        String directory="C:\\CVS\\yourPathToProject";
        //send commands to CVS and shows the resulting screen
        public int sendCMD(String[] command) throws IOException, InterruptedException
            ProcessBuilder pb = new ProcessBuilder(command);
            pb.directory(new File(directory));
            pb.redirectErrorStream(true); // merge stdout and stderr
            Process p = pb.start();
            InputStreamReader isr = new  InputStreamReader(p.getInputStream());
            BufferedReader br = new BufferedReader(isr);
            String lineRead;
            StringBuilder buffer=new StringBuilder();
            System.out.println("Return of shell:");
            while ((lineRead = br.readLine()) != null)
                buffer.append(lineRead + "\n");
            System.out.println(buffer.toString());
            return p.waitFor();
        //send commands to CVS, send the password after the prompt and show the resulting screen
        public int sendDialogCMD(String[] command) throws IOException, InterruptedException
            ProcessBuilder pb = new ProcessBuilder(command);
            pb.directory(new File(directory));
            pb.redirectErrorStream(true); // merge stdout and stderr
            Process p = pb.start();
            PrintWriter writer = new PrintWriter( new OutputStreamWriter( p.getOutputStream() ));
            writer.println( password );
            writer.flush();
            InputStreamReader isr = new  InputStreamReader(p.getInputStream());
            BufferedReader br = new BufferedReader(isr);
            String lineRead;
            StringBuilder buffer=new StringBuilder();
            System.out.println("Return of shell:");
            while ((lineRead = br.readLine()) != null)
                buffer.append(lineRead + "\n");
            System.out.println(buffer.toString());
            return  p.waitFor();
        public static void main(String a[]) throws IOException, InterruptedException
            execCMD e=new execCMD();
            String[] command = new String[5];
            command[0] = "cvs";
            command[1] = "-q";
            command[2] = "-d";
            command[3] = ":pserver:yourUserID@localhost:2402/path/of/yourProject"; //in this case using CVS port 2402
            command[4] = "login";
            System.out.println("exit value=" + e.sendDialogCMD(command));
            command = new String[8];
            command[0] = "cvs";
            command[1] = "-q";
            command[2] = "-d";
            command[3] = ":pserver:yourUserID@localhost:2402/path/of/yourProject";
            command[4] = "-n";
            command[5] = "-q";
            command[6] = "update";
            command[7] = "-dA";
            System.out.println("exit value=" + e.sendCMD(command));
    }It is possible to send the password on the same command, but I had problems when the password had the character '@' because CVSNT took it as the separator between the username and server name. In that case the command is: ":pserver:yourUserID:yourPassword@localhost:2402/path/of/yourProject"

  • How to execute a FrameMaker command (ExtendScript)

    Hi, does anyone know how to execute a command that your script did not create? In particular, I want to invoke the Edit > Update References command and launch that dialog box.
    Thanks,
    Russ

    Hi Russ, I think you want this:
    #target framemaker
    var cmd = app.GetNamedCommand ("Update");
    Fcodes ([cmd.Fcode]);
    If this isn't what you are looking for, let me know. Thanks. -Rick

Maybe you are looking for

  • DOM Parsing Exception in translator

    Hi We are hitting one issue in B2B/SOA 11g. BPEL instance is not getting created in 11g. Messages are picked from B2B queue and BPEL is failing while dequeing. It says that DOM Parsing Exception in translator. DOM parsing exception in inbound XSD tra

  • Sound

    I just turned on my MacBook Pro and notice my sound isn't working, I only get a "click, Click" everytime a sound is suppose to come out? Any ideas, I've never had this problem before. Thanks!

  • Cannot include a staic file in a JSP

    hi everybody, i have a requeirement as follows. i need to include a static html file in a JSP which IS NOT IN application server's jsp folder. i tried specifying actual file path and server's absolute path. not n use. can some body help me. applicati

  • Assign AW to a different tablespace

    Hello all, We would like to move an analytical workspace (Oracle 10.2.0.1) to a different tablespace. The owner user was originally assigned to a shared tablespace; however, it was changed to use a dedicated tablespace. I have attempted to export / i

  • Implement the UI design

    Hello everyone, I am getting started with flex 2 those days. It’s amazing. A lot of features make it easy to develop applications. I have little experience in ActionScript3.0 so I am eager to know the ability of AS3.0 to build a dynamic UI and to int