Sending unix command with java

Hi! I need to terminate program from server with "Ctrl+x" command.
How do I send this kind of command to the server?

Uh, by sending a
new String(new char[]{'\030'})?

Similar Messages

  • Invoking Unix command with java stored procedure

    Hi,
    I have a perfectly working environment and now I am trying to replicate the same in another server. I have a java stored procedure which invokes the Unix command using java Runtime.exec() in my code named "run". I am sure that the code is called and the java class run is resolved in oracle as I could see that in dba_java_resolvers dictionary. But I am not sure whether the function in java is called or whether a exception is thrown. how to identify this? Could there be any thing to do with settings in oracle side? please help me.
    Thanks in advance,
    Marutha

    Hi,
    Do you get any output while running the code?
    I'm testing similar solution and if there are any errors or Oracle can't execute the program due to permissions or other issues the error information will be displayed. Also in the Java class itself you need to catch exceptions and print stack trace to standard output.
    declare
    x number;
    begin
    dbms_output.enable(1000000);
    dbms_java.set_output(1000000);
    x:=system_command.run_command('testconnect.sh');
    dbms_output.put_line('Returned value='||x);
    exception
    when others then dbms_output.put_line('Sql error='||substr(sqlerrm,1,250));
    end;
    <system_command.run_command> - replace with a call to your java stored procedure.

  • How to send AT commands with JAVA?

    Hi,
    to get the cell id on a mobile phone I would like to send "AT+CREG=2" as an AT command to the mobile phone.
    Is there an API for getting network registration things like the cell identification of a gsm mobile phone or is there a possibility to access the mobile phone with AT commands?
    In MIDP 2.0, there is the possibility to access serial ports of a mobile phone. Probably this will work?
    I would be glad, if anyone could give me an idea. I'm investigation since weeks.
    greetings,
    Ralf.

    Hi
    i really don't know, but when i read your posting i thought that this may not be possible because it would break the java security concept.
    I guess, if you'd like to get any plattform/device related information you would need to have a vendor/device specific api.....
    but as i said, i don't know, i just guess...

  • Send SSH Command using java

    Ok. I hate this, but this is they way they have implemented it. I do not have access to the server code that this applicatio sits on, so I am only able to send specif commands with java through there interface. One of the commands for example is: password_reset "username" "new_password", there is also search_user "username", and uinfo "username". One of the command I really want to send is the password_reset command, but before I can do that I need to establish a ssh connection with username, and password. Not the username or password of the user that I am resetting, but the username and password of a user that has the privilege to reset passwords.
    anyway someone said I could just user the execCommand("password_reset " + username + " " + password ) command. If that is true then How do I do the ssh connection? any examples would be great. I have one, but it is not working for some reason.
    Here is the code:
    import java.io.BufferedOutputStream;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import com.trilead.ssh2.ChannelCondition;
    import com.trilead.ssh2.Connection;
    import com.trilead.ssh2.Session;
    import com.trilead.ssh2.StreamGobbler;
    public class SshTest
      public static void main(String[] args)
        Connection conn = null;
        try
          String host = "something.server.net";
          String user = "someuser";
          String user_pass = "somepassword";
          conn = new Connection(host);
          conn.connect();
          conn.authenticateWithPassword(user, user_pass);
          Session sess = conn.openSession();
          // vusertochange
          sess.execCommand("password_reset vusertochange newpasswordtest");
          /* Read all output with streamgobblers */
          StreamGobbler stdout = new StreamGobbler(sess.getStdout());
          StreamGobbler stderr = new StreamGobbler(sess.getStderr());
          /* Send the password (with a newline!) */
          BufferedOutputStream stdin = new BufferedOutputStream(sess.getStdin());
          stdin.flush();
          //stdin.close(); // This is optional
          /* Wait until the session has ended, maximum 60secs */
          int res = sess.waitForCondition(ChannelCondition.EOF, 60 * 1000);
          if ((res & ChannelCondition.EOF) == 0)
            throw new IOException("A timeout occured while reading the output.");
          /* OK, by now the whole output has been consumed by the two StreamGobblers */
          /* Close the session */
          sess.close();
          /* Show the result of STDERR */
          BufferedReader stderr_reader = new BufferedReader(new InputStreamReader(stderr));
          while (true)
            String line = stderr_reader.readLine();
            if (line == null)
              break;
            System.out.println("STDERR:" + line);
          /* Show the result of STDOUT */
          BufferedReader stdout_reader = new BufferedReader(new InputStreamReader(stdout));
          while (true)
            String line = stdout_reader.readLine();
            if (line == null)
              break;
            System.out.println("STDOUT:" + line);
        catch (Exception e)
          e.printStackTrace();
        finally
          if (conn != null)
            conn.close();
    The error I get is:
    STDOUT:cshell won't execute arbitrary command 'password_reset vusertochange newpasswordtest'
    any ideas what I am doing wrong?

    orozcom wrote:
    STDOUT:cshell won't execute arbitrary command 'password_reset vusertochange newpasswordtest'It sounds like the permissions with the user you're connecting with won't allow this operation.
    Don't know much about this, but maybe try 'su' and then 'password_reset ...' instead?

  • How to execute unix command in java  or jsp

    have a peace day,
    please send some sample code for
    "execute the unix command in java or jsp"
    thank you
    regards
    rex

    i execute this coding
    its compiling. while running i get the error " java.io.IOException: CreateProcess: \ls-l error=2 "
    import java.io.*;
    import java.util.*;
    public class Test
       public static void main(String[] args) throws Exception
         try
              String[] cmd = {"/ls-l"};
    Runtime.getRuntime().exec(cmd);
         catch (Exception e)
               System.out.println(e);
      }what can i do for that
    thank u

  • Can't Set Remote Login OFF via Send Unix Command systemsetup

    Trying to use the System Setup->Remote Login template in ARD to turn off Remote Login (SSH) in Sharing panel of System Preferences on Mac that is administered through Apple Remote Desktop.
    In Apple Remote Desktop (ARD), I select the client machine, then choose "Send Unix Command..." from the "Manage" menu. In resultant window, I pick "System Setup->Remote Login (SSH) from the "Template" drop down box in the upper right. That populates the upper window with Unix commands. I edit/change the "on" to "off" and tell the dialog to Run command as User: root, then click on "Send" button.
    Progress bar goes forever with no change.
    I can turn off Remote Login via ARD by controlling each client machine via an ARD WINDOW, then navigating to the Sharing Preference pane, but that process is tedious when performing for multiple client Macs.
    Strange, but I CAN use the "Send Unix Command..." outlined above to turn ON Remote Login, and get the status of Remote Login ("systemsetup -getremotelogin"). Just can't turn OFF Remote Login (quickly/efficiently).
    man systemsetup suggests I need to write the command as "setremotelogin -f off" but that failed with an improper command syntax error.
    Thoughts?

    It’s waiting for you to type a confirmation. If you run this command on the command line normally, you’ll see the message:
    Do you really want to turn remote login off? If you do, you will lose this connection and can only turn it back on locally at the server (yes/no)?
    Use this command instead:
    systemsetup -f -setremotelogin off

  • Send Unix Command Miscellaneous/Login template missing

    I'm wondering why the " Apple Remote Desktop" Administrator Guide depicts "Login Users"
    as an option in the default templates menu of the Send Unix Command/Templates/Miscellaneous/Login users ?
    In my actual ARD 3.2.2 Admin, the template menu list skips that command option.
    Also during my attempt to implement the osa script for simultaneous logins, I used a 'sudo'
    (which I shouldn't have). And now my screen savers won't activate on my login screens.
    So now I worry about my screens being burned with the login window image.
    Any ideas on how to undo my sudo?

    yes, click "user:" and type in "root", then remove "sudo" from your script.
    whenever you need to run a script as sudo, use the user 'root' and remove 'sudo' from the script.

  • Send Unix command won't work under 10.2.8

    So I am running this command in a lab of 10.2.8 machines. I go to send Unix Command then I put this in:
    Send Unix Command
    user: root
    osascript -e 'tell application "System Events" to keystroke "map"'; \
    osascript -e 'tell application "System Events" to keystroke tab'; \
    osascript -e 'tell application "System Events" to delay 0.5'; \
    osascript -e 'tell application "System Events" to keystroke "map"'; \
    osascript -e 'tell application "System Events" to delay 0.5'; \
    osascript -e 'tell application "System Events" to keystroke return'
    Then I check Display all output.
    Then I check Run command as User: Root
    Then I send it.
    After that in the Display all output shows me this.
    cms132-30 (64.8.180.103)
    /bin/bash: Send: command not found
    /bin/bash: user:: command not found
    execution error: System Events got an error: NSCannotCreateScriptCommandError (10)
    execution error: System Events got an error: NSCannotCreateScriptCommandError (10)
    execution error: System Events got an error: NSCannotCreateScriptCommandError (10)
    execution error: System Events got an error: NSCannotCreateScriptCommandError (10)
    So I close that window and see an error message by that machine that says:
    Error: 1 "execution error: system events got an error: NSCannotCreateScriptCommandError (10)"
    So what is wrong with this? It works fine with 10.3.9 but not with 10.2.8
    Imac   Mac OS X (10.2.x)  

    It doesn't appear that the System Events under 10.2.x responds to the keystroke command (it doesn't appear in the AppleScript Dictionary.)

  • Problem in executing a unix command through java

    hi
    i'm trying to execute unix command through java
    simple shell command like "ls -l >test " but i'm not able to see the result.
    there are no error messages.
    Code is:
    import java.lang.Runtime.*;
    class ExecDemo
         public static void main(String[] args)
              Runtime r=Runtime.getRuntime();
              Process p=null;
              try
                   p=r.exec("ls -l > test");
              catch (Exception e)
                   System.out.println("Error executing nedit.");
    }can anyone help please.

    get the the inputStream of the runtime object after executing the command.
    now use the readLine() function until it becomes null.
    egs: with reference to ur code.
    InputStream is=p.getInputStream()
    while(is!=null)
    String s=is.readLine();
    if the command don't execute try giving the full path also like /sbin/ls -l

  • Execute unix commands from Java

    Hi,
    I have a client application running on windows. This client should connect to a unix server and check for the existence of a file and display the result as "File found/File not found". In order to connect from windows to the unix server, I used the sockets and the connection is successfully established. The second part is to check for the presence of the file in unix server. I searched in google.com and the option I found to execute a unix command from java is the "Runtime.exec()". Runtime.exec is considered as the less effective (not a favorable) one.
    Is there any other option available (other than the Runtime) to execute the unix command from java? Can you please let me know.
    Thanks a lot
    Aishu

    So, please let me know how I can execute the above unix commands without Runtime.exec()You have a client and a server.
    You want something to run on the server, not the client.
    That means that something must in fact being running on the server before the client does anything at all.
    For example telnet. Or a J2EE server application.
    So is something like that running?
    If not then there absolutely no way to do what you want, even with Runtime.exec().
    If yes then what you do depends on what is running. So Runtime.exec() would be pointless if a J2EE server was running.

  • Execute an Unix command with pipe

    Hi,
    How do I execute a unix command with pipe from JAVA runTime.exec(cmd)? for example: "ls -l |wc -l"
    should return number of files. However, there is no output result. If I use "ls -l" as command argument, it gives file list.
    Here is my program:
    public static void main(String[] args) {
    try {
    Runtime runCmd = Runtime.getRuntime();
    System.out.println("sys testing");
    Process retProc = runCmd.exec(args[0]);
    BufferedReader bread = new BufferedReader
    (new InputStreamReader(retProc.getInputStream()) );
    String out = bread.readLine();
    while ( out != null ) {
    System.out.println(out);
    out = bread.readLine();
    DataOutputStream outSt = new DataOutputStream(retProc.getOutputStream() );
    outSt.writeChars(args[1]);
    outSt.flush();
    } catch (Exception ie) {
    ie.printStackTrace();
    Thanks in advance,
    Jeff

    I got my answer !
    No need to reply

  • How to run Unix command with Pipe ( | )?

    Dear Friends,
    I have to execute the below unix command through java program.
    *ps -ewwo pid,args | grep -E "abc.sh|xyz.jar" | gawk '{ print $1 }' | wc -l*
    My code to execute this command is,
    Runtime run = Runtime.getRuntime();
    File workDir = new File("/root/sat");
    String psCmd = "ps -ewwo pid,args | grep -E \"abc.sh|xyz.jar \" | gawk '{ print $1 }' | wc -l";
    Process process = run.exec(psCmd, null, workDir);
              String line;
              int i = process.waitFor() ;
              if(i == 0) {
              BufferedReader buf = new BufferedReader( new InputStreamReader( process.getInputStream() ) ) ;
              while ( ( line = buf.readLine() ) != null )
                   System.out.println("Line - ["+line+"]") ;
              } else {
                   BufferedReader stdErr = new BufferedReader(new InputStreamReader(process.getErrorStream()));
                   // read the output from the command
                   while ((line = stdErr.readLine()) != null) {
                   System.out.println(line);
                   }When i execute this command, i'm getting output as,
    ERROR: Garbage option.
    When i analyse the above error, i found that, the PIPE ( | ) command is not supported through java.
    Could anyone please help me how to execute the above unix command (with | ) in java?
    Thanks in advance,
    Sathish

    The pipe has to be interpreted by a shell so you need
    String[] psCmd =
        "sh",
        "-c"
        "ps -ewwo pid,args | grep -E \"abc.sh|xyz.jar \" | gawk '{ print $1 }' | wc -l"
    Process process = run.exec(psCmd, null, workDir);You should also read, re-read and then implement the recommendations in the 4 sections of http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html .

  • Send UNIX Command Authentication?

    I'm using a script suggested at MacEnterprise http://macenterprise.org/content/view/240/140/ that binds a client to AD and OD via the ARD send UNIX command.
    I'm having an issue with the dsconfigldap line. If I send it via ARD with no user logged in on the remote I get an "Unable to obtain auth rights to update DirectoryService LDAP configuration." error. If I login to the remote or send the same command from the terminal, all is OK.
    I've tried using sudo, but that requires a password. I'd like to be able to send this command to mutiple machines without having to log into them.
    Any suggestions?
    Regards
    Dave

    yes, click "user:" and type in "root", then remove "sudo" from your script.
    whenever you need to run a script as sudo, use the user 'root' and remove 'sudo' from the script.

  • Using ARD to send UNIX command to add item to dock

    The ARD 3 Admin Guide, page 132, says the following command sequence will install an item in the dock of the target computer(s):
    4) Type or paste the following UNIX command (replace /PathToApplication with your own path to the desired application, and be sure to include the application file extension, .app):
    defaults write com.apple.dock persistent-apps -array-add '<dict><key>tiledata</
    key><dict><key>file-data</key>
    <dict><key>CFURLString</key><string>/Path_ToApplication
    </string><key>_CFURLStringType</key><integer>0</integer></dict>
    </dict></dict>';killall -HUP Dock
    Use “persistent-others” instead of “persistent-apps” if the item is anything other than an application.
    I am unable to make it work. Could anyone help with the correct syntax or suggestions as to how to perform a remote addition to the target computer dock.

    Do you have JSS? I ask because your script contains the word JAMF allot.. if you do have a jss, is there a reason your trying to use ARD instead of your JSS to run this script?
    When issuing the script from ARD as a send unix command, Have you cosnidered using the option to run command as user "root" ?
    are you sure you want to do this? the script look like it dose more then just disable the isite. And do you know how to undo this if you change your mind?

  • The built-in Send UNIX Command templates include 'Login User'

    On page 144 of the Administrator's Guide.pdf is the title The built-in Send UNIX Command templates include:
    Under Miscellaneous it has as the first command "Login User" however it isn't listed for me.
    Upon further investigation I discovered in /Applications/Remote Desktop.app/Contents/Resources/English.lproj/UnixCommandTask.strings on line 75 presetLoginUser = "Login User";
    Also noted in the MacEnterprise video 2006-04-18_hres.mov at 00:23:07 it is not listed.
    I'm aware of the the scripts capable of doing this, I would just like to know why it is not available in the built-in commands or am I missing something?
    Thanks to anyone who can help me answer this question.

    No, you're not missing anything. The missing template was reported as a bug (or incorrect documentation) several times, but for some unknown Apple didn't fix the problem, either by including the template (missing perhaps because the script is unreliable with Mac OS X 10.4) or removing the reference from the manual, before ARD 3 was released.

Maybe you are looking for

  • Printing with my HP Laserjet 1100 in Snow Leopard & hpijs

    I have the DB25 to usb cable connected to the mini-centronix to db25 cable that is attached to my printer.  I have downloaded the hpijs packages from the linux foundation.  I think this should work except, after adding the printer and send a job to i

  • Sender File Adapter Behaviour

    Hi everyone, Could it be possible to create a  XML with plain structure from flatfile that is with out recordset. Eg., my flatfile will be like              name1,age1,sal1 name2,age2,sal2 I have to get the xml as <Recordset>   <name>name1</name>   <

  • Ora 00918 normalizing problem using cartesian product

    I am using a cartesian product to normalise a table. Is there a better way of doing this to avoid the 00918 error? Thanks in advance ... select /* select clause */ from z_dvo_proj_milestone_summary t1, z_dvo_proj_milestone_summary t2 where /* where c

  • After 300 cycles, is the battery problem considered normal?

    I now have the dreaded "Macbook won't work unless plugged in" problem. Mine does recognize the battery at various percentages up to 100% and will charge it if it runs down (which it slowly will in sleep mode as I can unplug it then). Purchased the co

  • FM SWW_WI_ADMIN_CANCEL takes time to execute

    Hi All, I have used FM SWW_WI_ADMIN_CANCEL in a report to logically delete workitems. When i execute the FM through SE37 it completes execution within seconds. However when i execute the report , time taken for execution of the FM is very high ( almo