Help in running top comman in java

hi frineds i want to run top command in java and store tht input into a file....any pls give suggestions.i will be thank full to u.
bye
keerthi.

Can you read? Why don't you read manual for top?
Start "top b n 1" and read output as easy as any other output.

Similar Messages

  • Running Top command in Java

    hi friends,
    when i run Top command in Linux from java by using Runtime.getRuntime.exec(), it is giving the following error---
    top: tcgetattr() failed : Invalid Argument
    While this command is working properly from shell.

    when i run Top command in Linux from java by using
    Runtime.getRuntime.exec(), it is giving the following
    error---
    top: tcgetattr() failed : Invalid Argument
    command is working properly from shell.top needs a terminal to run; it's a silly and ugly little program. When you
    fire up a process using the exec() method you don't have a terminal
    environment for the process. Try to run 'ps' instead.
    kind regards,
    Jos

  • Help with running external programs within java

    Hi,
    I'm new here, and not sure whether i'm in the right place for this, but i thought i'd give it a shot anyway!
    Basically i have a fortran program already written, that takes in the name of a text file as an input. I'm wanting to create a user interface to create this text file, and then i would have a button or something to enable me to then run the fortran program and input the file all from the user interface, and get rid of the need to manually run the fortran program.
    Firstly, is this even possible?! Is it difficult to program and get to work?! Does anyone have any suggestions or guidance on this.
    Thanks

    @Op.
    ..and here are two links related to that.
    http://java.sun.com/developer/JDCTechTips/2003/tt0304.html
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Help on running   lp command from java

    Hi
    How should i be able to print a String from my java program to the printer in Unix Platform.
    I am able to print a file using the follwing lp command
    lp -d <printername> <filename>.
    what should be the exact syntax to print a string ,I am using the following command but it doesnot work
    lp -d <printername> - <string>
    In my application I create a temporary file ,then print the file and delete the file as it contains some imp data,but this approach will not work always because if the file is deleted before the printing is completed then it won't be printed.So what should be a good approach for the same??.
    Regards
    Ravindra

    Hi
    How should i be able to print a String from my java
    program to the printer in Unix Platform.
    I am able to print a file using the follwing lp
    command
    lp -d <printername> <filename>.
    what should be the exact syntax to print a string ,I
    am using the following command but it doesnot work
    lp -d <printername> - <string>
    The right syntax for Unix is: echo "<string>" |lp -d <printername>
    Regards.

  • I keep on getting this error when i try to copy files to my 2T Time Capsule, Please help im running out of space on my MacBook Pro.... The operation can't be completed because an unexpected error occurred (error code -50)

    I keep on getting this error when i try to copy files to my 2T Time Capsule, Please help im running out of space on my MacBook Pro....
    The operation can’t be completed because an unexpected error occurred (error code -50)

    I would get an external drive today and copy all your stuff off the TC.. forget trying to load more onto it. There is a good chance after 3years (A 2TB should be only about 2years tops), the disk or the TC itself is on the way out. Do it immediately. If TM is also failing to backup you need to recognise symtoms of impending doom.
    Unfortunately the error messages are archane and it is hard to discover their meaning.
    You also cannot verify a network drive.. you can verify the TM sparsebundle though so do that.
    A5. http://pondini.org/TM/Troubleshooting.html
    Reboot the whole network from off.. certainly if you run later OS it can simply lose the drive..
    If you still fail to be able to copy to the TC.. then get that external and copy off it. Tell us if you can do that.

  • Running ls command from Java stroed procedure no output

    Hi ,
    I am trying to run ls command from java stored procedure in oracle
    Process p = Runtime.getRuntime().exec("ls");
    BufferedReader stdInput = new BufferedReader(new
    InputStreamReader(p.getInputStream()));
    BufferedReader stdError = new BufferedReader(new
    InputStreamReader(p.getErrorStream()));
    // read the output from the command
    System.out.println("output of the command run:\n");
    while ((s = stdInput.readLine()) != null) {
    System.out.println(s);
    from java stored procedure in oracle.
    i get output of println statments but it does not go into while loop to print from stdInput.
    Result of running Java stored procedure is -
    output of the command run:
    Call completed.
    when i run the program on client side it works fine.
    Has anybody tried this from java stroed procedure.
    Thanks,
    Jag

    Jag,
    Actually, the question of whether it works for me seems to depend on the version of the OS (or Oracle). On RedHat Linux (Oracle 8.1.6) it didn't work at all, but on Solaris (Oracle 9.0.2) it did. Here's the output from that run:
    SQL> /
    output of the command run:
    init.ora
    initDBPart9i.DBPSun01.ora
    initdw.ora
    lkDBPART9I
    orapw
    orapwDBPart9i
    spfileDBPart9i.ora
    Done
    PL/SQL procedure successfully completed.
    But, I did need to change a line of your code to this:
    Process p = Runtime.getRuntime().exec("/usr/bin/ls");
    your original was:
    Process p = Runtime.getRuntime().exec("ls");
    You might consider, if possible, use of some of the Java File classes instead of ls, as this might make things more predictable for you. There were some examples in oramag.com a few months ago, but they were pretty simple (you might not need them).
    Hope this helps,
    -Dan
    http://www.compuware.com/products/devpartner/db/oracle_debug.htm
    Debug PL/SQL and Java in the Oracle Database

  • How to run DOS command in Java environment?

    Can i run DOS command in Java environment?
    I did like this:
    Runtime r = Runtime.getRuntime();
    r.exec("cmd.exe");
    r.exec("set classpath=%CLASSPATH%;.\\tmp")
    but failed.
    However if I run the java command, it runs successfully.
    r.exec("javac Test.java");
    r.exec("java Test");
    how should I do so that i can run the DOS commands metioned above in Java Environment?
    thanks a lot.

    Have a look at http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    This may help. I wonder if this is ok ?
    Runtime r= Runtime.getRuntime();
    r.exec("cmd.exe /C set classpath=%CLASSPATH%;.\\tmp\"");

  • Executing the top command through Java in linux

    I am trying to execute the top command in Java as
    Runtime.getRuntime().exec("top -n 1 >a.log");
    But the command is not working in linux only through java.When i run the same command through the prompt it is working fine.Also all other commands are working fine.Is there any issue with top in linux?

    flounder wrote:
    Try reading [this article|http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html]. If it does not answer your problem then try seaching for other similar articles.
    The cited article does provide an answer to the problem since it explains how the shell meta character '>' must be interpretted by a shell. The code as presented does not invoke a shell.

  • Running batch files thraugh java by passing parameters

    Hi
    I want to run a batch file by passing some parameters.
    Eg: copy.bat "D:\live\hoe.txt" "D:\test"
    while doing this from command prompt its working and i have written some java code for running this batch file.
    String live="D:\\live\\how.txt";
    String test="D:\\test";
    String bat="D:\\copy.bat";
    String[] command = new String[3];
    command[0] = bat;
    command[1] = live;
    command[2] = test;
    try {
    Runtime.getRuntime().exec(command);
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    but this time its not copying the file;
    Please help.

    Just another cross poster.
    [http://www.java-forums.org/new-java/15005-running-batch-files-thraugh-java-passing-parameters.html]
    db

  • Help with Run Time Error Please....

    I got this Run Time error when I tried to execute a Swing program I was trying to run and I was wondering if anyone could explain what it meant and how I could go about fixing the situation. The program ran with no problem when I executed it yesterday but this morning, It failed for some reason .
    My Classes name is GUIcheck.java
    Exception in thread "main" java.lang.UnsupportedClassVersionError: GUIcheck (Unsupported major.minor version 49.0)
            at java.lang.ClassLoader.defineClass0(Native Method)
            at java.lang.ClassLoader.defineClass(Unknown Source)
            at java.security.SecureClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.access$100(Unknown Source)
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    I have posted the program below for your viewing ..
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class GUIcheck
        public static void main(String args[])
        JFrame.setDefaultLookAndFeelDecorated(true);
        JFrame frame = new JFrame ("Student Data Sheet");
        //Frame.setDefaultLookAndFeelDecorated(true);
       //Create the top panel.  This panel will use the grid layout and
       //will contain two labels (name and Social Security Number) and
       //two text boxes (nameTextField and ssTextField)
       JPanel topPanel = new JPanel(new GridLayout (2, 2, 5, 5));
       JLabel nameLabel = new JLabel ("Name:");
       topPanel.add(nameLabel);
       JTextField nameTextField = new JTextField(10);
       topPanel.add(nameTextField);
       JLabel ssLabel = new JLabel ("Social Security Number:");
       topPanel.add(ssLabel);
      JPasswordField ssTextField = new JPasswordField(10);
      topPanel.add(ssTextField);
      //Place the topPanel on the North side of the frame
      Container contentPane = frame.getContentPane();
      contentPane.add (topPanel, BorderLayout.NORTH);
      //Create the center panel.  It will be placed in the center of the
      //frame.  It will contain two sub panels.  One sub panel will contain
      //labels (Select sources of news and information and Classification).
      //The second sub panel will contain check boxes and radio buttons)
      JPanel centerPanel = new JPanel (new BorderLayout ());
      JPanel centerTopPanel = new JPanel (new GridLayout (1, 2, 5, 5));
      JLabel sourceLabel = new JLabel
                 ("Select sources of news and information");
      centerTopPanel.add (sourceLabel);
      JLabel classLabel = new JLabel ("Classification");
      centerTopPanel.add (classLabel);
      centerPanel.add (centerTopPanel, BorderLayout.NORTH);
      JPanel centerBottomPanel = new JPanel (new GridLayout (1, 2, 5, 5));
      JPanel checkBoxPanel = new JPanel (new GridLayout (3, 1, 5, 1));
      JCheckBox newspaperCheckBox = new JCheckBox ("Newspaper");
      checkBoxPanel.add (newspaperCheckBox);
    JCheckBox tvCheckBox = new JCheckBox ("TV");
    checkBoxPanel.add (tvCheckBox);
    JCheckBox friendsCheckBox = new JCheckBox ("Friends");
    checkBoxPanel.add (friendsCheckBox);
    centerBottomPanel.add (checkBoxPanel);
    JPanel radioButtonPanel = new JPanel (new GridLayout (4, 1, 5, 1));
    JRadioButton freshmanRadioButton = new JRadioButton ("Freshman");
    radioButtonPanel.add (freshmanRadioButton);
    JRadioButton sophomoreRadioButton = new JRadioButton ("Sophomore");
    radioButtonPanel.add (sophomoreRadioButton);
    JRadioButton juniorRadioButton = new JRadioButton ("Junior");
    radioButtonPanel.add (juniorRadioButton);
    JRadioButton seniorRadioButton = new JRadioButton ("Senior");
    radioButtonPanel.add (seniorRadioButton);
    centerBottomPanel.add (radioButtonPanel);
    centerPanel.add (centerBottomPanel, BorderLayout.SOUTH);
    contentPane.add (centerPanel, BorderLayout.CENTER);
    //creation of button group deleted
    //buttonPanel will contain buttons and will be placed at south side
    //of the frame
    JPanel buttonPanel = new JPanel(new GridLayout (1, 2, 5, 5));
    JButton submitButton = new JButton ("Submit");
    buttonPanel.add (submitButton);
    JButton exitButton = new JButton ("Exit");
    buttonPanel.add (exitButton);
    contentPane.add (buttonPanel, BorderLayout.SOUTH);
      }//end main
    }

    I do have the 1.5 at the moment and I still get the same error. I have removed other instances of JRE from my computer and retried but it still persists... What else can I do?
    Java Newbie

  • Help with running multiple threads

    I'm new to programming with threads. I want to know how to run
    multiple threads at the same time. Particularly for making games
    in Java which I'm also begining to learn. For running multiple
    threads at the same time, do you have to put two run() methods
    in the source? If not then how do you make two threads or more
    run at the same time?
    Thanks for helping.

    For running multiple
    threads at the same time, do you have to put two run()
    methods
    in the source? Hi there,
    Each thread is presumably performing a task. You may be performing the same task multiple times or be performing different tasks at once. Either way, each task would typically be contained within the run() method of a class. This class would either be a subclass of java.lang.Thread (extends Thread) or would be an implementation of java.lang.Runnable (implements Runnable). In either case, you would define a method with signature (public void run()...). The difference comes into play when you wish to actually perform one of these tasks. With a subclass of Thread, you would simply perform:
    new MyTask().start();
    With an implementation of Runnable, you would do this:
    new Thread(new MyTask()).start();
    This assumes you don't need to monitor the threads, won't be sending any messages to your tasks or any such thing. If that were the case, you would need to tuck away those returns to new MyTask() for later access.
    In order to launch two threads simultaneously, you would have something along the lines of:
    new MyTask().start();
    new MyOtherTask().start();
    Now it is perfectly possible that MyTask() would complete before MyOtherTask() managed to start in which case it wouldn't appear as if you had actually had multiple threads running, but for non-trivial tasks, the two will likely overlap. And of course, in a game, these tasks would likely be launched in response to user input, which means that you wouldn't have any control over when or in what order they executed.
    Anyhow, it's as simple as that. You should also consider following the Java Threading trail which shows a simple example of using multiple threads. You can find it at:
    http://java.sun.com/docs/books/tutorial/essential/threads/index.html
    Regards,
    Lynn

  • TS1363 I tried to print off some of the iTunes advice but my computer froze. I re-booted the computer and ran the diagnostic test again but now "Secure link to itunes store failed"  AND " itunes helper not running."

    I just tried to print off some itunes advice but my computer froze.  I re-booted it and ran the ipod diagnostic test again to get back to the screen I was on. This time "Secure Link to  i tunes store failed" AND "i tunes helper not running" both appeared.   Please help, all I can see is "Appears in Windows but not iTunes" at the top of the screen.  Even though I only vaguely know what that means, I don't think that's the help I need.    

    I just tried to print off some itunes advice but my computer froze.  I re-booted it and ran the ipod diagnostic test again to get back to the screen I was on. This time "Secure Link to  i tunes store failed" AND "i tunes helper not running" both appeared.   Please help, all I can see is "Appears in Windows but not iTunes" at the top of the screen.  Even though I only vaguely know what that means, I don't think that's the help I need.    

  • How cud I run odi using a java application.

    HI,
    I need the location of the jar files that cud help me to run odi using a java application.
    I am unable to find jar file which is responsible for the invoking ODI using the classes in the package named
    "oracle.odi.sdk.invocation".
    I found this package name from doc
    regards,
    Palash Chatterjee

    It's going to depend on the application in question.

  • Run Perl script in JAVA

    Can we run perl scripts in java, still supporting perl API?
    Thanks a lot for help!

    I haven't tried it but I think 6.0 supports some
    scripting.But NOT perl!Sorry, I didn't mean some Perl Scripting. I meant some scripting and I wasn't sure what languages.

  • Problems running external programs from java

    Hello.
    I wrote a pair of perl scripts and a GUI in java to run them. The first perl script just read the files in one directory makes some changes to the names of the files and then group all this files in a set of new directories. The other perl scripts takes all this new files and calls BLAST sequence alignment program and perform some alignments among these sequences. I tested this scripts and they work fine.
    The problem comes when I try to run them for the JAVA GUI. I use RunTime and when I need to run the first perl script it all works well, but when The call to the second perl script is made the program fisishes without doing anything at all. I found out that the problem is that when running the script from the Java GUI it's not able to find BLAST program. So I guess that Java is not really starting a terminal session and it doesn't read my bash_profile to find out the path to my programs.
    So, my question is if anyone knows a method to tell Java to load all this paths in the bash_proflie file so all of my scripts work???.
    I have no idea is this can be done and how so any advice would be really wellcome.
    By the way, my java version is 1.4.2 and my OS is Mac OS X 10.3
    Thanks a lot , Julio

    Invoke /bin/sh -c and give it your program's full path with.
    (To understand what I've written, maybe reading
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps_p.html
    http://mindprod.com/jgloss/exec.html
    and
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html
    (especially the exec(String[] cmdarray) method)
    might help)
    -T-

Maybe you are looking for

  • VS 2005 CR integrated report connection with more than one database

    Hello, I am using VS 2005 to make a reporting application. I am using the Crystal Reports Viewer and I need to know how to integrate the report login information for more than one database. Here is the VB code I have for one connection: Imports Cryst

  • Why can't I watch YouTube allow a sudden

    It started yesterday suddenly is my iPad and iPod not able to watch YouTube videos. I can go into the sight and everything but it says that every kip try to opened is not available. Same thing goes for my iPod. But it works perfectly fine on my Samsu

  • BP User Defined Attributes -- Error

    Hi experts!! The customer i am working on needed some extra fields on the Accounts screen page, so i defined all User Defiened Attributes from 1 to 10 and added them from the Node MARKETING of the component BP_HEAD. When i try to save the Account (af

  • Logical hostname netmask

    I evaluate a Solaris cluster (x86_64). I want to evaluate "High availability mysql database replication with solaris zone clsuter" -from sun BluePrints .... and I have a problem with netmask for logical hostname. Cluster set ths for "C class" (dec: 2

  • Slight file size discrepencies between identical photos?

    While looking at the metadata of photos I am working with, I have noticed that identical photos in every single aspect of pertinent metadata (lense, focal, other various exif data) happens to have a slight file size discrepency.  For instance, a dscf