Is it possible to execute SAPGUI scripts from java program?

Hi everyone..
     I need to develop an java applications that executes the SAPGUI script or any technique that execute set of transaction as client.
     Is it possible to execute SAPGUI scripts from java program? if so, how it can be achieved? is there any other technique to achieve above mention scenario?.
     it will be more helpful, if docs related to that are shared..
     Thanks in advance

Oh, bummer. Would be much more convenient if I could just use iTunes for everything. Can't stand WMP. I wonder if WinAmp might be a good compromise?
Thanks for this answer . . .
Sharon

Similar Messages

  • How execute Unix script from java?

    Can I execute Unix script from java?

    Yes. Using ProcessBuilder. And read [When Runtime.exec() wont|http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html]. It's old, but pretty much all of it is still true.

  • How can i execute vb scripts in java program

    hi
    how can i execute any batch files or any other exe files (vb scripts) from java programs
    thanks

    Hi,
    You use Runtime.exec to execute commands / exe-files. See the documentation (and remember that it will only work on windows):
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html
    /Kaj

  • How to execute SAPGUI script from the command line?

    I have created a script and would like to execute it from the command line. There must be some flag that goes with SAPGUI.EXE. Any help appreciated.
    Thanks,
    Jeff

    Hi Jeff,
    the best way to do this is to run the script using the Windows Script Host, for example like this:
    cscript myscript.vbs
    This will execute the script which in turn can access SAP GUI. You may however have to make sure the script attaches to the correct session.
    Best regards,
    Christian

  • Executing unix scripts from java...

    Hi guys,
    I'm pretty new at this java stuff, but can someone tell me if it's possible to have a java object that connects to a specific unix box through a given IP and Port and execute a Unix shell command? The shell script creates a file that will be later ftp'ed from the UX box back to the PC I ran the java program from. Any ideas?
    Thanks in advance.

    Yes I thank it can be done. I have not done it but you prob can do it through tcp/ip useing ServerSocket and socket class.Make a server with the ServerSocket class on the linux box that is listening to the port and when it gets the right signal from your client on your pc/win the server will activate the sell script with the Runtime.getRuntime().exec(shellscript);
    Well just a thought GOOD LUCK

  • Error while trying to execute a unix shell script from java program

    Hi
    I have written a program to execute a unix shell script in a remote machine. I am using J2ssh libraries to estabilish the session connection with the remote box.The program is successfully able to connect and authenticate with the box.
    The runtime .exec() is been implemented to execute the shell script.I have given below the code snippet.
    try {
         File file_location = new File("/usr/bin/");
         String file_location1 = "/opt/app/Hyperion/scripts/daily";
         String a_mib_name = "test.sh";
         String cmd[] = new String[] {"/usr/bin/bash", file_location1, a_mib_name};
         Runtime rtime = Runtime.getRuntime();
         Process p = rtime.exec(cmd, null, file_location);
    System.out.println( "Connected to the server1" );
    BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line = br.readLine();
    while(line !=null)
    System.out.println(line);
    line = br.readLine();
    br.close();
    p.getErrorStream ().close ();
    p.getOutputStream().close();
    int retVal = p.waitFor();
    System.out.println("wait " + retVal);
    //session.executeCommand("ls");
    catch (IOException ex) {
    I get an error message
    Connected to the server
    java.io.IOException: Cannot run program "/usr/bin/bash" (in directory "\usr\bin"
    ): CreateProcess error=3, The system cannot find the path specified
    at java.lang.ProcessBuilder.start(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at SftpConnect.main(SftpConnect.java:143)
    Caused by: java.io.IOException: CreateProcess error=3, The system cannot find th
    e path specified
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(Unknown Source)
    at java.lang.ProcessImpl.start(Unknown Source)
    I am sure of the file path where the bash.sh and test.sh are located.
    Am i missing something? Any help would be greatly appreciated.
    Thanks
    Senthil

    Hi, I am using a simple program to connect to a RMI server and execute shell script. I use the Runtime.exec aommand to do the same.
    The script is sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul
    The script when run from the server, gives no errors. But when ran using rthe above method in java, gives errors as follows,
    Mycode:
    String command = "/bin/sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul";
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec(command);
    int exitVal = proc.exitValue();
    System.out.println("Process exitValue: " + exitVal);
    java.io.IOException: CreateProcess: /bin/sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul error=3
         at java.lang.ProcessImpl.create(Native Method)
         at java.lang.ProcessImpl.<init>(Unknown Source)
         at java.lang.ProcessImpl.start(Unknown Source)
         at java.lang.ProcessBuilder.start(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at DecryptTest.main(DecryptTest.java:18)
    Can anyone please help

  • Error while executing unix shell script from java program

    Hi All,
    I am trying to execute unix shell script from a java program using Runtime.execute() method by passing script name and additional arguments.
    Code snippet :
    Java Class :
    try{
         String fileName ="test.ksh";
         String argValue ="satish"; // value passed to the script
         String exeParam = "/usr/bin/ksh "+fileName+" "+argValue;
         Process proc = Runtime.getRuntime().exec(exeParam);
         int exitValue = proc.waitFor();
         sop("Exit Value  is : "+exitValue);
    catch(Exception e)
    e.printStackTrace();
    }Test.ksh
      export -- application realated paths..
      nohup  abc.exe 1> test.log 2>&1;
      $1
      exit.By running the above java class , i am getting exit Value: 139 and log file test.log of 0 bytes.
    when i am running the same command (/usr/bin/ksh test.ksh satish) manually, it's calling abc.exe file successfully
    and able generate the logs properly.
    Pls let us know where exactly i am stuck..
    Thanks in advance,
    Regards,
    Satish

    Hi Sabre,
    As per the guidelines provided by the article, i had done below changes..
    InputStream is = null;
    InputStreamReader iStreamReader = null;
    BufferedReader bReader = null;
    String line = null;
    try{
    String fileName ="test.ksh";
    String argValue ="satish"; // value passed to the script
    String exeParam = "/usr/bin/ksh "+fileName+" "+argValue;
    Process proc = Runtime.getRuntime().exec(exeParam);
    is = proc.getErrorStream();
    iStreamReader = new InputStreamReader(is);
    bReader = new BufferedReader(iStreamReader);
    System.out.println("<ERROR>");
    while((line = bReader.readLine()) != null)
    System.out.println("Error is : "+line);
    System.out.println("</ERROR>");
    int exitValue = proc.waitFor();
    sop("Exit Value is : "+exitValue);
    catch(Exception e)
    e.printStackTrace();
    Now , it's showing something like..
    <ERROR>
    </ERROR>

  • Problem executing Unix script from Java...

    Hi there, I'm having trouble executing a unix script from a java program. The script receives multiple parameters and it seems that one of them ( or more ) is not well interpreted. When I run the script directly from a shell, the script executes without any errors. But, when I run the exact same script with the exact same parameters, it does not work.
    Here is the command to execute the script with all the parameters that is executed from the shell ( with success ) and also from the java program ( with errors ):
    /z/opus/dcap/intfu001.csh 'NODEBUG^NOTKPROF^NOSTACK' opus dcap JACQUES JACQUES '2625781' 'ORA$PIPE$001D00D70001' JOB^DEBUG^SINISIMU^STATPROD^DECTIDANC^81^503^4080^86^87^151^97^98^99 BUT^N^N^SPRI^0^13^24^3^J^05^N^19^19^19 >> /tmp/switcher8.999.null.pgm.test
    And here is my portion of code that executes the script:
    Runtime wShell = Runtime.getRuntime();
    Process wProc = wShell.exec(cmd_unix_final);
    wProc.waitFor();
    return wProc.exitValue();
    Please give me your thoughts on this!
    Thanks in advance!

    Ok.
    Let's proceed surgically, else we'll never solve or overcome anything.
    In the last your reply you wrote:
    the normal output is what I get when the script runs successfully, the script first prints a few things
    and then does stuff that takes at least 2 or 3 secondsWhat do you mean?
    -Finally have you got your script correctly executed?
    The stuffs you spoke of are really performed?
    If this is the case I can't see the prob.
    Is your concern only about exitValue() for it doesn't let you distinguish programmatically
    the success or failure of the script execution?
    Of course you surely already have a routine in your java code to handle
    exceptional situations of errors from the script.
    And the "normal output" is just what you must parse to detect those errors.
    Then who cares about exitValue() in this case?
    Don't invoke it, relay on the stdout and stderr of the script.
    -Or you get only a deceiving standard output
    that let you think the script execution went alright, while instead it didn't.
    In this case we have to investigate some other thing.
    I can't still exclude that the problem isn't related with the buffer size of the stdout
    allocated by the environment to the subprocess. You spoke of few things printed out.
    Be explicit. What's the size of the output you get?
    And is the "normal output" complete till the very last char
    or is it truncated from somewhere on?
    Also it's important that you hit a ps command after the java main process terminates
    (or simply when waitFor() returns) and see if the script subprocess hung up.
    As an alternative approach directly call your pro*C code from Java through JNI, instead of translating it.
    1. Exec.java
    public class Exec{
         static{
              System.loadLibrary("Exec");
         public static native void proCFunct();
         public static void main( String[] args){
              proCFunct();
    }2. javac Exec.java
    3. javah Exec
    4.Exec.c
    #include "Exec.h"
    JNIEXPORT void JNICALL Java_Exec_proCFunct(JNIEnv * a, jclass b){
         //here call the function that executes the script
    5. cc -G -I$JAVA_HOME/include -I$JAVA_HOME/include/solaris -I$YOUR_INCLUDES Exec.c -o libExec.so
    6. setenv LD_LIBRARY_PATH .
    7. java Exec

  • How to execute SAPgui.exe from java code

    Hi All,
    Can any one provide me the exe file name of SAP GUI related.
    I need to call the SAP GUI related exe file from java.
    i tried with a small java prog which executes the exe files.
    it works fine with notepad.exe,javac.exe . But i am unable to execute the SAPgui.exe.
    This is my java code
    try{
         Runtime rt=Runtime.getRuntime();
    //String str= "C:
    WINNT
    system32
    notepad.exe";
    //Process pp=rt.exec("C:
    j2sdk1.4.2_08
    bin
    javac");
    Process pp=rt.exec("C:
    Program Files
    SAP
    FrontEnd
    SAPgui
    SAPgui.exe");
    BufferedReader br=new BufferedReader(new InputStreamReader(pp.getErrorStream()));
                         String line;
                         while ((line = br.readLine()) != null) {
                             System.out.println(line);
              }catch(Exception e){
                   System.out.println(e);
    and may i pass any additional parameters inorder to invoke this exe.
    Please share your ideas abt  this problem.
    Its Urgent PLZ
    Adv Thanks
    Regds
    Phani.

    hi Rajesh,
    here my complete code:
              try{
                   Runtime rt=Runtime.getRuntime();
    //               String str= "C:\Programmi\SAP\FrontEnd\SAPgui\saplogon.exe";
                   String str= "C:\Programmi\SAP\FrontEnd\SAPgui\Sapgui.exe 10.113.10.201 00";
                   //               Process pp=rt.exec("C:\j2sdk1.4.2_08\bin\javac");
                   Process pp=rt.exec(str);
                   BufferedReader br=new BufferedReader(new InputStreamReader(pp.getErrorStream()));
                   String line;
                   while ((line = br.readLine()) != null) {
                   System.out.println(line);
                   }catch(Exception e){
                   System.out.println(e);
    Please note that system number is only two digit and in your case is 00.
    Another important think, i'm using the italian version of windows, so the program directory is c:\programmi, please change into c:\program files, or you can modify your code to be language indipendend using an system environment variable (if exist).
    Hope this help
    Francesco

  • Is it Possible to Run SQL Script from Java prog

    Hello
    Is there any API by which we can run SQl Script file ,
    Just by giving database configration parameters and SQL Script file Path ,it will execute that script automatically

    You can excute SQL statemetns throught JDBC, but that doesn't have a facility to read those statements from a file. You'd have to write code to read the file and create and execute statements through JDBC. That should be pretty straightforward though.
    It's conceivable that there's a third party library out there that does it, if you know what to look for.
    If you're not familiar with JDBC, check out http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/

  • Execute UNIX  script from java not working

    Hi
    I am having difficulty running my java program to execute UNIX script on a Windows box. Here is my code.
    public boolean executeScript() {
              try {
                   String testScript= "WEB-INF/scripts/test.sh";
                   File file = new File(copyToQaScript);
                   System.out.println(file.getAbsolutePath());
                   Process proc = Runtime.getRuntime().exec(file.getAbsolutePath());
              } catch (IOException ioe) {
                   ioe.printStackTrace();
                   logger.error(ioe);
              } catch (RuntimeException re) {
                   re.printStackTrace();
                   logger.error(re);
              } catch (Exception e) {
                   e.printStackTrace();
                   logger.error(e);
              return true;
         }When I execute this method, I am getting IOException as below.
    java.io.IOException: CreateProcess: C:\tomcat-5.0.28\webapps\myProject\WEB-INF\scripts\test.sh error=193
    Can anyone help me? Thanks.

    kminkeller wrote:
    Yes I have Cygwin installed. I am quite aware of that thanks Sabre.Then you need something like
          String[] command = {"bash","/home/sabre/bin/fred.sh"};
            Process p = Runtime.getRuntime().exec(command);
      if the executabe directory (/home/sabre/bin in my case) is not on the PATH or
          String[] command = {"bash","fred.sh"};
            Process p = Runtime.getRuntime().exec(command);
      if it is.

  • Executing Unix shell from Java Program

    Hi,
    I have written a java application using Maverick J2sshtools API which connects to a Unix box using SSH.The program authenticates with the remote box successfully,but It dosen't return the environment info or execute the test script.Have attached the complete code.
    package shellInteraction;
    import com.maverick.ssh.*;
    import com.maverick.ssh2.Ssh2Client;
    import com.maverick.ssh2.Ssh2Context;
    import com.maverick.ssh2.Ssh2PasswordAuthentication;
    import com.sshtools.net.*;
    import java.io.*;
    import java.util.Iterator;
    import java.util.Vector;
    public class JavaShell{
         public static void main(String[] args) {
              SshConnector con = null;
              SshClient ssh = null;
              ShellProcess process = null;
              Shell shell = null;     
              try{
                   // Create a session to remote host
                   con = SshConnector.getInstance();
                   ssh = connectionSetup(con);
                   System.out.println(ssh);
                   // Start a session and do basic IO
                   if (ssh.isAuthenticated()) {
                        shell = new Shell(ssh);
                        System.out.println("Authenticated");
                        if(shell.getEnvironment().hasEnvironmentVariable("hostname"))
                             System.out.println("We are connected to " + shell.getEnvironment().getEnvironmentVariable("hostname"));
                        //System.out.println("Remote operating system is " + shell.getEnvironment().getOperatingSystem());
                   //     boolean isWindows = shell.getEnvironment().getOSType()==ShellEnvironment.OS_WINDOWS;
                        //if(shell.getEnvironment().hasEnvironmentVariable("USERPROFILE")) {
                             //System.out.println("User home is " + shell.getEnvironment().getEnvironmentVariable("USERPROFILE"));
                        //} else if(shell.getEnvironment().hasEnvironmentVariable("HOME")) {
                             //System.out.println("User home is " + shell.getEnvironment().getEnvironmentVariable("HOME"));
                        // Commands only executed for Unix OS
                        //if(!isWindows) {
                             // Execute a script
                             traverseDirectory(shell);
                   shell.exit();
                   ssh.disconnect();
                   System.out.println("Shell has exited");
              } catch(Throwable t) {
                   t.printStackTrace();
         private static void traverseDirectory(Shell shell) throws Exception{
              System.out.println("\n\nTraverse Directory");
              // Execute a simple script than prints a directory tree
              ShellProcess process = shell.execute("bash test.sh ");
              try{
                   process.expect("Total directories", 1000, true);
                   System.out.print(process.toString());
              } catch (ShellTimeoutException ex1) {
                   System.out.println("TRAVERSE Expect operation timed out. Sending interrupt to kill the process");
                   process.interrupt();
              }finally {
                   process.close();
         static private Ssh2Client connectionSetup(SshConnector con)throws SshException{
              Ssh2Client ssh = null;
              final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
              try {
                   System.out.print("Hostname: ");
                   String hostname = reader.readLine();
                   int idx = hostname.indexOf(':');
                   int port = 22;
                   if(idx > -1) {
                        port = Integer.parseInt(hostname.substring(idx+1));
                        hostname = hostname.substring(0, idx);
                   System.out.print("Username [Enter for " + System.getProperty("user.name") + "]: ");
                   String username = reader.readLine();
                   if(username==null || username.trim().equals(""))
                        username = System.getProperty("user.name");
                   System.out.println("Connecting to " + hostname);
                   * Create an SshConnector instance
                   con = SshConnector.getInstance();
                   // Lets do some host key verification
                   HostKeyVerification hkv = new PasswordHostKey();
                   con.setSupportedVersions(SshConnector.SSH2);
                   * Set our preferred public key type
                   con.getContext(SshConnector.SSH2).setHostKeyVerification(hkv);
                   ((Ssh2Context)con.getContext(SshConnector.SSH2)).setPreferredPublicKey(Ssh2Context.PUBLIC_KEY_SSHDSS);
                   * Connect to the host
                   ssh = (Ssh2Client)con.connect(new SocketTransport(hostname, port), username, true);
                   * Authenticate the user using password authentication
                   Ssh2PasswordAuthentication passwordAuthentication = new Ssh2PasswordAuthentication();
                   System.out.print("Password: ");
                   passwordAuthentication.setPassword(reader.readLine());
                   if(ssh.authenticate(passwordAuthentication)!=SshAuthentication.COMPLETE) {
                        System.out.println("Authentication failed!");
                        System.exit(0);
              }catch(Exception ex1) {
                   throw new SshException(ex1.getMessage(), ex1.getCause());
              return ssh;
    When I execute the program
    Hostname:****
    Username [Enter for thaya]: **
    Connecting to CATL
    The connected host's key (ssh-dss) is
    b6:85:91:6b:8b:ea:cb:40:b5:6f:01:2e:66:78:7f:62
    Password: *****
    SSH2 CATLMSXP62:22 [kex=diffie-hellman-group1-sha1 hostkey=ssh-dss client->server=aes128-cbc,hmac-sha1,none server->client=aes128-cbc,hmac-sha1,none]
    Authenticated
    Traverse Directory
    com.maverick.ssh.ShellTimeoutException: The shell did not return to the prompt in the given timeout period 10000ms
         at com.maverick.ssh.Shell.A(Unknown Source)
         at com.maverick.ssh.Shell.execute(Unknown Source)
         at shellInteraction.ShellInteraction.traverseDirectory(ShellInteraction.java:108)
         at shellInteraction.ShellInteraction.main(ShellInteraction.java:68)
    This is the error message what i get.

    use code tags if you want a response,
    ive done the same thing once using
    ssh2.ethz.ch ie:
    import ch.ethz.ssh2.Connection;
    import ch.ethz.ssh2.ServerHostKeyVerifier;
    import ch.ethz.ssh2.Session;
    the code looked something like this:
    try
                   conn.connect(new ServerHostKeyVerifier() {
                        public boolean verifyServerHostKey(String hostname, int port, String serverHostKeyAlgorithm, byte[] serverHostKey) throws Exception {
                             return true;
                  conn.authenticateWithPassword(username, password);
                  try {
                       sess = conn.openSession();
                   } catch (java.lang.IllegalStateException e) {
                        return;
    //                    JOptionPane.showMessageDialog(null, "Could not autheticate.\nCheck username and password.\nTerminating.", "Authentication Failed", JOptionPane.ERROR_MESSAGE);
    //                    System.exit(-1);
                   sess.requestPTY("dumb", 50, 50, 0, 0, null);
                   sess.startShell();
              }and after that sess has getStdIn() and getStdOut() that get the streams from which you read and write.

  • Execute Unix command from Java program running on windows

    Hello,
    I need to write a java program that fetches file count in a particular unix machine directory. But java program will be running on windows machine.
    The program should execute unix list command and fetch the output of that command.
    Can anyone help me on this?
    Thanks.

    Hi there,
    I had a similiar problem, though years ago. It was to have a java program execute any other. Lately, I've had to have a java program running on a unix machine execute a shell script. Entirely two different scenarios. I'm not sure what you will need for your app, but look into this:
    Java Native Interface for executing C/C++ code.
    C/C++ Code for launching the program you need to run.
    java.lang.Runtime(?).exec(....)
    With a combination of that stuff, you can make a launcher for any os that has Java running on it, and with Runtime, you can exec() pretty near any sort of unix shell or app command you'd like.
    Good luck.
    Tim

  • 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 .msi files from java program

    Hi friends,
    i have written a java program which invokes and thereby execute any executable files like .exe and .bat.
    So its working fine with .exe and .bat files, but it is not working with .msi files.......can you please help me how can i execute .msi files as well??
    public class Executeexe {
         public static void main(String ar[])
              try
              Process p=null;
              Runtime rt=Runtime.getRuntime();
              p=rt.exec("D:\\mysql-essential-5.0.83-win32.msi");
              p.waitFor();
    catch(Exception e)
    }here is the program

    Make sure that the command that's being exec'd works from the cmd line.
    Then read this article and do what it says:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    Then if you still are having problems explain what "...it is not working with .msi files..." really means, and provide a [SSCCE Example program|http://mindprod.com/jgloss/sscce.html]

Maybe you are looking for

  • Win XP SP3 PC wired to WRT54G router repeatedly crashes

    I have a Win XP SP3 desktop that is wired (not wireless) to WRT54G router  (v 3.0 router with latest firmware version 4.21.1). The PC repeatedly freezes when I connect to internet using IE or Firefox and has to be re-booted using power button. The fo

  • Drive marked discs - what can I do ?

    The Windows XP original disc that I have been using with bootcamp failed to install because of concentric circle markings on the surface. It did work originally but I needed to reinstall after having a new hard drive fitted. My local PC chappie has t

  • Allowing Shockwave Player to run for non-admins

    Hi all, I see the following problem on and off for years now, with Adobe Flash and in particular Adobe Shockwave Player. I have a school that has a Windows 7 lab. Shockwave Player 11.6 is installed as part of the base image. It shows up in "Programs

  • CUA history for child systems

    Hi all I have seen quite a few forum entries about change history and tables to see the mapping of roles to users, such as: Table AGR_USERS (actual assignments) Table USLA04 (actual assignments in a CUA central system) SUIM report RSSCD100_PFCG for v

  • Mac won't let me move files into a folder bc it THINKS there are duplicate files - but they're not

    Mac won't let me move files into a folder bc it THINKS there are duplicate files - but they're not. There are hundreds of what it thinks are duplicates. How can I get it to let me put them all into a folder and create unique names? If I do one file a