Best method to execute a command on a remote machine?

I am currently using runtime.exec to execute commands on the machine where my java gui is running. What I would like to do is to execute the programs on a remote networked machine.
What should I be looking at? creating sockets, using rmi?
eventually it would be good to utilise ssh for the connection.
Any help is much appreciated.

haven't really looked at this properly, was really after some advice on what methods would be useful.....
I can see that a telnet type solution can work... need to look further at rmi i think

Similar Messages

  • Could not able to execute FTP commands in windows server machines 2012/ windows server 2008.

    Could not able to execute FTP commands in windows server machines 2012/ windows server 2008.
    From windows server 2012 and windows server 2008, Opened port 20,21,22 in firewall bidirectionally. After Establishing connection by passing credentials  230 log in  successful.
    ftp commands executing getting as " 425 Use Port or PASV first" , "500 Illegal PORT command".
    But I could able to do windows client machines like windows 7 and windows 8 with same environment
    Note : Firewall ports are opened.  have tested by making firewall down to avoid filters. 
    Pandiyan Muthuraman

    Hi Pandiyan Muthuraman,
    Did you mean even you disable or open the related port the FTP issue still exist? I found this errors most time occur when we use the ISA firewall and the FTP configured passive
    mode, if you have ISA firewall please refer the following KB to fix this issue.
    How to enable passive CERN FTP connections through ISA Server 2000, 2004, or 2006
    http://support.microsoft.com/kb/300641
    The have a specific form for the IIS question, if you have the further IIS related question you can ask in IIS forum.
    IIS support forum
    http://forums.iis.net/
    Thanks for your understanding and support
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Is it possible to execute OS commands/files on remote server using SOA Suite/BPEL , just like we have JCA adapter File/FTP to exchange files across servers ?

    I am working on technical process automation requirement wherein files need to be exchanged and executed as well , SOA workflow capabilities are helping but I could not find a way to remote OS comman execution yet.
    Please help.
    Thanks

    The whole idea of SOA is to run web services located anywhere. So I believe if you can expose the runtime in remote servers as services then you will be able to call those services like any other web service.
    Or if you requirement is to execute files on the SOA server itself then you can use the java embedding activity.

  • How to execute OS command on client's machine

    Hi,
    How to invoke for example MsWord on client's machine from APEX?
    I'm trying to use MSWord mail merge.
    Andrija

    Hello Andrija,
    I did it without Oracle BI. BI is $40,000 per processor.
    I'll sell it for less ):
    A little different !!!:
    1. I am using Office 2007
    2. I use HOST command on the server.
    Ok, here how I did it.
    1. Create Word 2007 template with XML token defined and store it in the database, which will be dynamically replace by the database values selected.
    2. Create the HOST command procedure using JAVA, which you can find example in this forum.
    3. Create Oracle DIRECTORY to point to a physical directory on Windows, UNIX or Linux
    4. Create a "customXml" under this directory.
    5. Retrieve your WORD template and put it in the Oracle DIRECTORY
    6. Output your data into a XML format to "customXml" directory
    7. use "$ORACLE_HOME/bin/zip" to zip this 2 files together.
    8. Return the WORD doc to the screen.
    9. Here you go
    --John                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Execute a script on a remote machine - possible?

    I am sorry if this sounds silly - what I would like to know is if its possible for a java program executing on one machine to execute a shell script that resides on another machine.
    That script in turn invokes a java program which does some other stuff.
    I know the way to do it would be to eliminate the script altogether and have the java program on the other box listen on a port and have it accept connections from the host machine. But a client is insistent he doesnt want it that way and I am not even sure if its possible to do as he says. I am aware that I can use the Runtime and Process classes to invoke a script on the same machine that the java application executes on, but is it possible to invoke a script on another machine?
    Thanks,
    Ram.

    If they're running the server on a *NIX box, you might check into inetd or xinetd - this is basically a proxy that listens on a certain port, starts a process running when it gets a request on that port, hands the request to that process, and then the process exits while xinetd waits for the next request.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Forms6: Execute program in remote machine?

    Hi,
    I'm trying to execute a program in a remote machine. For exemple: I can use the function 'host ('notepad')' and the notepad executes in the machine running the .fmx. How can I execute a command in a remote machine running Unix? Is there a function?
    I'm using Developer6 (forms).
    Thanks.

    You should be able to use <cfexecute...> to do this,
    you will have to
    make sure all the connections and permissions are set up.
    Just remember that by default, at least on windows systems,
    CF is
    configured to only have access and permissions to the local
    system, you
    will need to modify this if it has not been done.

  • Executing a command using Runtime Class

    How to execute a command on a differnet machine with different ipaddress using Runtime Class
    My code is
    String[] cmd = new String[3];
    cmd[0] = "192.1...../c:/WINNT/system32/cmd.exe" ;
    cmd[1] = "/C" ;
    cmd[2] = args[0];
    Runtime rt = Runtime.getRuntime();
    System.out.println("Execing " + cmd[0] + " " + cmd[1]
    + " " + cmd[2]);
    Process proc = rt.exec(cmd);
    // any error???
    int exitVal = proc.waitFor();
    System.out.println("ExitValue: " + exitVal);
    This is not Working

    I have same issue. Actually when I use cmd.exe /c set in java code and if I run the java code in DOS propmt, it retrieves all latest user Environment variable values. But if I run the code in windows batch file, it is not retrieveing the latest user environment values until I reboot my computer, Do you know how to get user environment value with out rebooting machine??????

  • Need to execute Linux Commands in JSP

    Hi I am Srinivas,
    I am new to this forum,
    {color:#ff0000}I want to execute Linux Commands(which is remotely connected through putty) in a JSP Page.{color}
    {color:#0000ff}My requirement is to display df -h output on a JSP page.{color}
    This is because we will monitor disk space at regular intervals.
    Can anyone help me in this regard.
    Thanks & Regards
    Srinivas V.
    Edited by: Srini-XIUS on Mar 24, 2008 2:06 AM

    I think you might need the java 'robot' class.
    However, a JSP page displayed on a browser is running in a secure enviornment that will probably not let you access the computer its running on. Instead, create a serlvet back on the server that runs the robot class. The servlet will send the data to the jsp page for display. The jsp page can send commands to the servlet which will execute it via its robot class.

  • Running commands on VMs remotely

    Hi Everyone
    New to all of this so please bear with me!
    Starting a new project and looking to compare between the use of Hyper V and ESXi.  
    The project is to grab vms regardless of state, turn them on and execute scripts stored on a vm drive. The script execution has to be performed / issued by a user. C# is the main underlying code but we can potentially put in references to use powershell
    scripts / whatever else if we can achieve this using hyper v.
    I know from doing a bit of reading on ESXi that we can do this using a number of ways - vmrun to start, stop and run commands on the actual vm itself. using other vmware libraries and APIs.
    I have read that powershell commands include starting vms, taking snapshots, shutting down vms but I was wondering if we can get into the actual VM remotely / somehow in-order to, for example, run a script which is stored on that VMs C drive.
    Has anyone tried this / is it do-able? -  I have had no luck finding any examples of what we need. 
    Kind Regards,
    Ashley

    I have a few things that I have done historically.
    Really, you have two options.  a WMI (API) call or a WinRM / PowerShell remoting call.
    The difference between the two is 1) security settings and 2) ease of use.
    For WinRM the security needs to be more open then WMI.  But, it is far easier to script as you simply open a remote session and you keep scripting along in the remote shell (the tricky part is pulling values back to the local session).  With WMI
    you always get the values back since you never spawn into another session.
    Below is a WinRM example of using WinRM and returning some value back:
    It executes a WMI command on the remote machine to fin the file I am looking for (as that is faster) and then I read the file with the script.
    # This block of script executes remotely and returns the content of hte CtxSta.config file.>
    $sta = invoke-command -Session $s -ScriptBlock {
    $staArray = get-wmiobject CIM_DataFile -filter 'Extension="config" and FileName="CtxSta"'
    # If IIS Integration is installed there could be multiples, this is the one that CSG is hard coded to use.
    foreach ($e in $staArray) {
    if ($e.Path -match "citrix\\system32") {
    $sta = $e
    get-content -path ([string]$sta.Name)
    # We have returned to local execution.
    foreach ($e in $sta) {
    switch -wildcard ($e) {
    "UID*" {
    $e = $e -replace "UID", ""
    $e = $e -replace "=", ""
    $e = $e -replace " ", ""
    $staId = $e
    $staId
    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.

  • Copying Files From a Remote Machine through "rcp" command not working.

    Hi All,
    I'm a new comer to this famous forum. I was trying to go through the PDF "Solaris Advanced User's Guide" .So in chapter 9-"Using the network" i came across "Copying Files From a Remote Machine". And the syntax was "rcp machinename:source destination" . And i got another note. It is like
    "The rcp command enables you to copy files from one machine to another. This command uses the remote machine's /etc/hosts.equiv and /etc/passwd files to determine whether you have unchallenged access privileges. The syntax for rcp is similar to the command syntax for cp.".
    But i maintained remote machine's IP address in my system's /etc/hosts file. But still i am unable to do the rcp from remote system to my system or vice versa.
    Always i am getting error message " **Connection refused**".
    Therefore please some one guide me how to perform the " Copying Files From a Remote Machine" through rcp command.
    Reghards
    Kartik

    Hi
    The inconvenience of using scp is that you have to type the password every time you stablish a connection. You can work around this, adding a key into the remote hosts_allow file. This implies in more maintenance.
    From the rcp man page:
    +rcp does not prompt for passwords. It either  uses  Kerberos authentication which is enabled through command-line options or your current local user name must exist on  hostname  and allow remote command execution by rsh(1).+
    From the rsh man page:
    + If you omit command, instead of executing a single command, rsh logs you in on the remote host using rlogin(1).+
    By default, rlogin is disabled on Solaris 10
    [SunOS 5.10/bash] root@wgtsinf01:/store/sun/operating-systems
    # svcs -a|grep -i rlog
    disabled       May_11   svc:/network/login:rloginSo, to use rcp you have to enable the rlogin service and set up all the configuration files. Particularly, as already suggested, I too suggest you to use scp. :)
    Cheers
    -- Andreas
    Edited by: Bank_Of_New_Zealand on 15/06/2009 13:09

  • Running commands on a remote UNIX machine

    I am very new to Java. Just wanted to get that out of the way. :)
    I have installed Websphere Application Developer and Websphere Application Server on my Windows 2000 PC and intend to use this machine to host some things I will create.
    One of the main things my tool will do is to maintain/check the status of a few AIX (IBM's UNIX) machines. The way I will do that is to run commands on these remote machines and examine their output.
    For example, someone would click a button on a servlet and it would then rsh to the machine and run "ps -ef" or whatnot and post the output back to the user.
    Usually I could do this from another UNIX machine using rsh or telnetting to it, however, my machine is windows 2000.
    Is there anyway I could do this?
    Any help would be much appreciated.
    Mike

    try looking into the apache jakarta commons library
    for telnet and other useful classes.
    http://jakarta.apache.org/commons/net/apidocs/index.ht
    Oh, I like this answer better - can I change mine? If you can do it from "inside" Java like this, all sorts of ugliness involving where things get installed on various machines and versions of Windows just go away.
    Grant

  • Problem when trying to execute OS Command in Notification Method

    Hi gurus,
    I am using EMGC 10.2.0.2 on windows XP, I have created a Notification method with a OS Command which is a batch file which intern calls a perl script to send a mail notification. When there is an alert the Alert History logs says that 1 OS Command is executed and show s the bat file name, but I am not getting any mail as expected. I have given the absolute path for bat file. What could be the reason for this and where can I find the logs for this knowing the status of OS command execution details.
    Thanks,
    Ashok Chava

    Hi bazza,
    My perl script is running fine in isolation no issues with that. I thought it may be becasue of the some time out issues then I have increased time from 30 second to 120 seconds by changing the property value "em.notification.os_cmd_timeout" in emoms.properties but with out any success. I dont have any logging messages put in the perl script I will check with that also. I have checked bat file by giving some logging messages the bat file eexcuting properly.
    Thanks,
    Ashok Chava.

  • Executing system commands query

    I'm only just starting to program Java although I do have a good grounding in programming other languages so it is probably more a question of familarity, but hopefully someone can answer this problem I am having.
    What I am trying to do is to execute TFTP on a Windows NT machine roughly every 5 seconds to get a file. To do this I have created a thread and within "public void run" I have a loop which contains something along the lines of:
    Runtime.getRuntime().exec( "C:\\WINNT\\system32\\tftp.exe <ipaddress> get <filename>" );
    Where I would specifiy a real IP address and filename.
    I then do a sleep on the current thread to make it pause for a while.
    The good news is it fetches the file every few seconds as I wanted. The bad news is it creates a new TFTP process each time and so it keeps using more and more memory.
    Now I'm sure there are better ways to do this but I am working things out as I go along. The finished program will use an infinite loop which will run out of memory.
    Can anyone recommend a solution or method to do this? Should I not bother with the thread, and what would be the best method to make it pause without killing processor time?
    If possible can anyone mail me directly. Thanks in advance.
    Mark.

    No I must quite specifically use TFTP. The scenario is information is entered via a FORM on a web page. The data is passed from the client to a server where I parse it using perl and write out the data in the necessary form to a file.
    The java file I am writing then runs continually fetching this file every few seconds for another program to read. The other program reads the data every few seconds and uses one of the fields in the file to identify if it has changed since the last time it was fetched, if so it can act on the new data.
    Using TFTP I can call it with a command line function to invoke TFTP to connect and fetch a file in one line. This seems much simpler using an existing executable than hand crafting code to do the same job.
    I've managed to write something in C++ which performs the task. Java seems a bit more ackwared as it discourages you using system commands as it means the code is not portable.
    However I originally wrote this as a Java file to expand my knowledge and as such I would like a proper solution.
    Thanks for the suggestion though. I will have a look just out of curiosity now.
    Mark.

  • Executing external commands (linux)

    Hello everybody,
    I have to execute a command from my java program but I have a problem, when I do something like this:
    input has the complet path to a file I have, output has the complete path to the output file cert has the complete path to a digital certificate file keyfile has the complete path to the privatekey file.
       command = "openca-sv sign -in " + input +".pem -out " + output +" -cert " +cert +" -keyfile " + key;
                   r = Runtime.getRuntime();
                    p = r.exec(comamnd);
                    p.waitFor();
                    System.out.println("output value:: " +p.exitValue());
                   InputStream stream  = r.exec(command).getErrorStream();
                   int resl = stream.read();
                   System.out.println("result: " +resl);I know java is finding the command. But why it doesn't end the right way?
    The output for this piece of code is something like this:
    Output value: 1
    result: 91
    I know that the output value 1 means that the command didn't finished successfully, but what is the meaning of the other value? 91??
    I have also tryed passing as arguments the names of the files without the complete path, but the result is the same.
    I have tryed to execute the command from a console but it ends successfully. I have also tryed from a console passing all the files path and files without path and it worked. What could be the problem? AFAIK the command was written in C
    Thanks for any help
    Jhonny

    Hello, thanks for your reply.
    I know java is finding the command.
    How do you know that? It's always best to assume that Runtime.exec doesn't know your PATH.Because when I give a bad path for the command java says in the console:
    java.io.IOException: java.io.IOException: /usr/openca-sv: not found
         at java.lang.UNIXProcess.<init>(UNIXProcess.java:143)
         at java.lang.Runtime.execInternal(Native Method)
         at java.lang.Runtime.exec(Runtime.java:566)
         at java.lang.Runtime.exec(Runtime.java:428)
         at java.lang.Runtime.exec(Runtime.java:364)
         at java.lang.Runtime.exec(Runtime.java:326)
         at Prueba.firmar(Prueba.java:125)
         at Prueba.main(Prueba.java:56)
    I know that the output value 1 means that the command didn't finished successfully, but what is the meaning of the other value? 91??
    It's the ASCII value of the first character printed to stderr.ok.
    I forgot to give another info, I'm working in eclipse 3.0
    Now what do you think?
    Thanks again,
    Johnny

  • Executing shell commands from Java.

    I want to execute shell commands in Java using the Runtime.exec( String ) method.
    The method works fine under Linux OS, but under Windows '98 the method didn't work at all!
    For example the following call: Runtime.exec( "dir" ) throws an exception showing that the command was not completed. If I replace dir with ls under Linux all is good. What is the problem with the Microsoft Windows '98 ? Is there any solution at my problem ?!
    thx in advance!

    hey JSarmis,
    You can help me... "ls" doesn't work for me on linux.. using Runtime.exec, some commands work, others don't... you may hold the key to what i need? How did u get "ls" to work?

Maybe you are looking for

  • Itunes will not open on Desktop PC.

    My daughters new ipod need to be restored to factory settings. Ikeep getting the message make sure that the network settings are correct and your network connections are active. I have checked and they are all ok. Can anyone suggest anything else? I

  • Creation of ZRPA_MARM in Retail

    Hello! I have created new info-object ZRPA_MARM in retail BW project. I want to know when ever we create a new Bespoke info-objects, WHY all the related tables are created in local instead of storing transport request where info-object is stored. for

  • One way trust relationship between different domain windows server 2012 in different forest

    I'd like to build trust correctly between the domains A.local and B.int. A.local is on a Windows 2012 . B.int is on a Windows 2012 . Both machines are connected to the same LAN. The forest level in A.local machine is Windows Server 2008 and The fores

  • Using a textfile to store ~300,000 - 1million records of data

    Hi all, I'm making a simple java program that will retrieve information, store it. Then the application would use the stored information. My thought was -- in order to make the java program work on all platforms, rather than use a database, i would j

  • Organizer Error Pop-Up

    I Have Elements 9 with Window 7 I have this problem.  I open Elements Organizer, once it opens an error box pops up.  It's say as follow, This application cannot be installed because this installer has been mis-configured. Then it says, Please contac