Save output of ping command in jtextarea

Hello friends,
In my program i made 1 screen, in that i put 1 textarea and 1 button.
When user press that button i want to run ping command and its output i want in textarea.
How can i do that, give fast reply its urgent for me.
Thanx

Hello!
My idea is:
Process proc=Runtime.getRuntime().exec("ping host");
BufferedReader in=new BufferedReader(new InputStreamReader(proc.getInputStream()));
(proc's output is piped to proc.getInputStream())
next use the code I've written in thread: http://forum.java.sun.com/thread.jsp?forum=31&thread=509892
or write your own thread that gets data from stream in and sleeps for example 1000ms after it.
Best wishes,
Arthur

Similar Messages

  • Save output of a command

    Hi all,
    I am trying to save the output of a command so I can read it and decide weather it completed successfully or not.  I am having trouble running the command though. It's working but the switches aren't.
    $Servers = Get-Content Servers.txt | Sort-Object
    ForEach ( $Server in $Servers ) {
    & PsExec.exe \\$Server 'C:\Program Files (x86)\progfolder\program.exe' option -t=$Duration -e=$email -c=$Comment -q=110
    When ran it complains I am not specifying any options/switches. Ideas?
    Thanks.

    Psexec can be very finicky with optional switches for the command you are trying to run through it.
    Try this and let me know if it works:
    $Servers = Get-Content Servers.txt | Sort-Object
    ForEach ( $Server in $Servers ) {
    & PsExec.exe \\$Server 'C:\Program Files (x86)\progfolder\program.exe' 'option -t=$Duration -e=$email -c=$Comment -q=110'
    Boe Prox
    Blog |
    Twitter
    PoshWSUS |
    PoshPAIG | PoshChat |
    PoshEventUI
    PowerShell Deep Dives Book

  • Problem with output string to command

    hey i have no idea why this aint working
    its a simple output string to command.
    what it is supposed to do is make a new directory given by the input string
    e.g. mkdir /home/luke/dep
    thanks for the help
    //methods input save files
         saveFile = JOptionPane.showInputDialog("Save Files To : ");
         //method command for saving files
         //Stream to write file
         FileOutputStream fout;          
         try { Process myProcess = Runtime.getRuntime().exec("mkdir" + saveFile );
          InputStreamReader myIStreamReader = new InputStreamReader(myProcess.getInputStream());
          fout = new FileOutputStream ("file.txt");
          while ((ch = myIStreamReader.read()) != -1) { new PrintStream(fout).print((char)ch); } }
              catch (IOException anIOException) { System.out.println(anIOException); }

    What you fail to understand is that "aint working" and "Problem with output string to command" tells us absolutely squat about what your problem is. This is the same as saying to the doctor "I'm sick" and expecting him to cure you. As mentioned by Enceph you need to provide details. Do you get error messages? If so post the entire error and indicate the line of code it occurs on. Do you get incorrect output? Then post what output you get, what output you expect. The more effort you put into your question the more effort others will put in their replies. So until you can manage to execute a little common sense then the only responses you will get will be flames. Now is your tiny little brain able to comprehend that?

  • Sysql - use SQL queries against output of linux commands

    Hello!
    Many linux commands have table-like output. Sometimes it is better to analyze such output as a real table in relational database. I have published prototype of utility that parses output of one or several linux commands, saves it in database and allows to make SQL queries to that data. Program is written on python and uses sqlite database engine.
    sysql at AUR
    sysql at Github
    Here is why I wrote it:
    * No need to remember command syntax to format command output - just select necessary fields in SQL query
    * No need to know sed, awk, head, join and other linux commands to manipulate with output - it's all SQLite
    * Table data is stored with meaningful column name and type (int, text, float, datetime etc)
    * All power of SQL can be used to query output (JOIN, WHERE, GROUP BY etc.)
    * To support new command, output parser must be developed only once and then can be shared with community to make life easier
    * All supported commands are kept in one place as set of python files, so it is easy to find out how to customize existing parsers or create new ones
    This is my first community contribution, so kindly ask everyone to share your opinions and advices on what can be done better. Thank you!
    Examples:
    Display help and list of available commands:
    sysql
    Display output of ps command:
    sysql ps
    Query output of lsblk command:
    sysql -q "SELECT device,uuid,filesystem FROM lsblk" lsblk
    Query output of several commands:
    sysql -q "SELECT ps.pid, ps.command, ps.elapsed_time, lsof.name FROM ps JOIN lsof ON ps.pid = lsof.pid WHERE name LIKE '%LISTEN%'" ps -e --- lsof -Pni4

    I am not sure, if I will ever use it, but I do think, this is an _amazing_ idea!
    You may consider something like a global repository for output parsers accessable directly via sysql.
    Last edited by myname (2013-11-24 09:16:59)

  • Save Output to: setting not being saved

    This has been driving me nuts for a couple of years, so I figured I'd finally ask if anyone else sees this behavior.
    My script grabs a PDF and converts each page to new, separate, PDF files using a custom name and number. There are three components: Ask for Finder Items, PDF to Images, and Make Finder Item Names Sequential.
    My problem appears in the PDF to Images part. I have the "Save Output to:" setting set to a folder ON my desktop (Outbox). Every time I open the script it has reverted to "Save Output to: Desktop". I can change it, run the script from within Automator, and it works fine. If I save it (or save-as), when I next open the script, it will have reverted to Desktop. I have tried every iteration I can think of to get it to remember to store the files in the correct folder, but it just won't save this setting.
    I am in the habit of just opening the script first, and changing the setting, then running the script before I have closed it, so this is no big deal -- but it does make it two more steps, which kinda defeats the whole purpose of automator.

    Understood, but you mentioned scripts and AppleScript is used extensively with workflows. If there aren't any in yours, then all I can suggest is peruse http://www.automatedworkflows.com/tips/podcast.html
    Also, see http://discussions.apple.com/thread.jspa?threadID=2039384 and Introduction to Automator tutorial at http://automator.us/leopard/video/index.html

  • Gnome Panel applet that shows output of system command.

    Hi all;
    Because of the recent hostile takeover of #archlinux channel by tilling WM fanatics..    I will ask here..
    Does any one know of a Gnome Panel applet that shows the output of system command of your choice?
    For people who Conky is a bit too much and they only want a simple piece of data available (like what is the current IP on ppp0 interface) like me..  this is a necessity.
    If its not in existence I would probably make one.. shouldn't take long, I also would like to hear if there is any interest.
    Thanks

    That's exactly what I was looking for!  Thank you!
    Changed code to:
    $dism = "X:\Windows\System32\Cmd.exe /c start CMD /k dism /apply-image /imagefile:D:\W7x86.wim /index:1 /applydir:C:\"
    And voila, new window opened with the live output of dism.
    new... and have a glazed over look about my eyes to prove it...

  • Need Help for Ping command?

    I have a basic question ,In windows machine we use ping -t IP address command for continous ping until we stop with Ctrl+C, so is there any method in cisco routers to use the Ping command for infinity until we stop manuallay.

    Every you may want to know about the ping commands is available here http://www.cisco.com/en/US/products/sw/iosswrel/ps1831/products_command_reference_chapter09186a00800d9840.html#1018913, and here http://www.cisco.com/en/US/products/sw/iosswrel/ps1831/products_command_reference_chapter09186a00800d9840.html#1019084
    Cheers,
    Josef.

  • Cannot read the output from windows command.

    Hello
    I have the following classes
    package cmd;
    import java.io.IOException;
    public class CMD {
        public CMD(){
            ProcessBuilder pb = new ProcessBuilder()
            .command("cmd.exe","/c","del *.*")
            .redirectErrorStream(false);
            Process p;
            try {
                p = pb.start();
                StreamGobbler errorGobbler = new StreamGobbler(p.getErrorStream(), "ERROR");
                // any output?
                StreamGobbler outputGobbler = new StreamGobbler(p.getInputStream(), "OUTPUT");
                // start gobblers
                outputGobbler.start();
                errorGobbler.start();
            } catch (IOException e) {
                // TODO Auto-generated catch block
            System.out.println("eee "+e.getMessage());;
        public static void main(String[] args) {
            System.out.println("x");
            new CMD();
            System.out.println("x");
    and
    package cmd;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    public class StreamGobbler extends Thread {
        InputStream is;
        String type;
        StreamGobbler(InputStream is, String type) {
            this.is = is;
            this.type = type;
        @Override
        public void run() {
            try {
                InputStreamReader isr = new InputStreamReader(is);
                BufferedReader br = new BufferedReader(isr);
                String line = null;
                while ((line = br.readLine()) != null)
                    System.out.println(type + "> " + line);
            catch (IOException ioe) {
                ioe.printStackTrace();
    Please note that I cannot seee the output from wndows command : del *.* and the java class execution does not finished.
    I I will replace the above command with the dir command then the output of the command is visible.
    Would you give me a hint about how to modify the above clases in order to parse the output of the del *.* ?
    Please note that the above example is important because I am developping a tool and it is mandatory for that tool to parse the output from a windows batch command.
    Best regards,

    Please note that I cannot seee the output from wndows command : del *.* and the java class execution does not finished.
    I I will replace the above command with the dir command then the output of the command is visible.
    Would you give me a hint about how to modify the above clases in order to parse the output of the del *.* ?
    No - but I will give you a hint about ProcessBuilder and how to develop software properly.
    Hint #1: Don't try to automate something that you don't know, or understand, how to do manually.
    a. Do you know how to execute 'del *.*' manually in a command window?
    b. Did you try that manually to see what happens?
    My guess is 'no'. If you had you would know that the response to a 'del *.*' command is going to be this:
    Are you sure (Y/N)?
    And your 'java class execution' doesn't finish because the 'del' command is waiting for you to answer that question.
    Hint #2: Don't try to use ProcessBuilder for an application that requires console input unless you first know how to provide that console input via your Java code.
    Your code will wait forever since it does NOT answer that question.
    Search the net and The Java Tutorials and  you can find examples of executing command line utilities. Then try those examples first and make sure that:
    1. They work for you
    2. You understand HOW they work
    Then you can modify those examples to do what you want to do.

  • Using subprocess in python3 to get output of a command

    Hi Friends. I am writing a python3 script for audacious to check the internet for album cover of the current playing song and then display it in conky. I am trying to call a command from python and get it's output:
    audtool current-song-tuple-data album
    but when i use this command in python like this:
    subprocess.check_output(["audtool", "current-song-tuple-data album"])
    i get the following error:
    Unknown command "current-song-tuple-data album".  Try "audtool help".
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python3.2/subprocess.py", line 522, in check_output
        raise CalledProcessError(retcode, cmd, output=output)
    subprocess.CalledProcessError: Command '['audtool', 'current-song-tuple-data album']' returned non-zero exit status 1
    Please , python experts on this forum, help me.

    @Pranavg1890: Please add solved to your thread title then.
    BTW: I found pexpect a good option for interacting with shell commands:
    http://sourceforge.net/projects/pexpect/
    It provides an easy way to deal with console output and react on certain patterns.

  • [svn:bz-trunk] 10026: Fixed a bug around handling ping commands while running load-testing-tool against Servlet-based endpoints .

    Revision: 10026
    Author:   [email protected]
    Date:     2009-09-04 10:28:18 -0700 (Fri, 04 Sep 2009)
    Log Message:
    Fixed a bug around handling ping commands while running load-testing-tool against Servlet-based endpoints.
    Modified Paths:
        blazeds/trunk/modules/core/src/flex/messaging/MessageBroker.java

  • Formatting string output in columns to a JtextArea

    Hello,
    I am pretty new to java and GUI's but i am working on a project that needs to output some statisitcs to a JtextArea. I need have all the data in an array and i want it to appear as
    First Name Last Name Points Rebounds Assists Minutes
    The last four columns are numbers but are stored as strings. I would like to find a way to format them into colums so that even though each name is a differing number of characters, each column will be flush left. Thanks.

    I strongly agree with Camikr, use Jtable is the best solution since you have arrays of data to be displayed
    I'll show you few tips that might be helped
    if you don't want the header part to appear you do this:
    JTable table = new JTable(..)
    table.getTableHeader().setPreferredSize(new Dimension(0,0));if you want the table to appear like JLabel maybe you can set like this:
    table.setBackground(UIManager.getColor("Panel.background"));
    table.setGridColor(UIManager.getColor("Panel.background"));so it will make the background and cell border color to be the same as panel
    if you insist to use table another work around is by formatting your jlabel using html code like this
    new JLabel("<html><table><td>First Name</td>.......</table></html>");

  • "Ping" command to Oracle server?

    Hi to all, I am using a connection pool to improve my application, and I am interested in checking the connections in the pool when they are to be used. I tried to use the method Connection.isClosed(), but this method returns false, even if I shutdown the DB (it seems not realize the shutting down state). So, it is not usefull. A connection pool implementation in JDC suggets to use getMetaData(), but it doesn't work because an SQLException is not thrown, even when the server is down. So, I am currently using:
    try{
    Statement dummyStmt = conn.createStatement();
    dummyStmt.close();
    }catch(SQLException e){
    The question is: Because this code will be executed each time a Connection is requested, I need it to be low cost and quick. Is this the best way to do it, or can I send a kind of "ping" command to Oracle?
    Thank you all in advance.

    >
    try{
    Statement dummyStmt = conn.createStatement();
    dummyStmt.close();
    }catch(SQLException e){
    The question is: Because this code will be executed
    each time a Connection is requested, I need it to be
    low cost and quick. Is this the best way to do it, or
    can I send a kind of "ping" command to Oracle?
    Actually I wouldn't think that would be sufficient since it doesn't need to actually send anything to the server to do that.
    I usually suggest sending "select 1 from dual".
    You might want to also consider doing in more often than just when a connection is requested. Oracle will time out connections. One of the points of a pool is to not to require the setup cost each time. To keep a connection active it has to do something periodically. The connection pool should do that (the above query can be what it does.)

  • Exchange server keeps throwing "Syntax error in Ping command request. (status 4)" for Ping

    We have exchange activesync client on Android. For some users, the exchange server sometimes responds with
    "Syntax error in Ping command request. (Status 4)"
    or
    "The Ping command request omitted required parameters. (status 3)"
    We logged the request we are sending and there does not seem to be anything wrong.  We could have collected server logs, but this issue happens only for some customers and customers are not comfortable collecting and sending us logs.
    Many times, it recovers and we stop getting the error after some time. But, for few users it never recovers.
    We need to yet collect the exchange server version.
    What is the best way to recover from such an error? (Sync?). We observed sometimes that if we send the same sync multiple times, server throws error "Identical Sync requests".
    Please help.

    Look at the two config files:
    /Library/Preferences/edu.mit.Kerberos
    /var/db/krb5kdc/kdc.log
    the Database is locked or in use message is due to a missing lock file.
    Look in /var/db/krb5kdc/ for principal.kadm5.lock
    Hope this gets you started
    - Leland

  • Hp 4100 and 4200 missing 1st ping command and others reply once you get your replies your

    all of a sudden my 4 hp printers  4100 and 4200 won't print at times. I will print a job and it did not get to the machine when that happens I ping the ip address of the printers and always the 1st reply has no responce and the others reply. On its own after the ping commands finish the waiting print job comes out on its own. My laniers and kyocera printers don;t fail at all any ideas?

    Download and run this utility: http://h20180.www2.hp.com/apps/Nav?h_pagetype=s-926&h_lang=en&h_client=s-h-e17-1&h_keyword=dg-NDU&ju...
    What does it say?
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • STAD BDC to save output file

    Dear All,
    I want to create a program with the BDC recording which saves output of STAD' TCode at my local system and want to schedule it in background so that i can get the daily log of transactions.
    I tried to create BDC with system date input but it's not working.
    Please let me know if there special settings for that.
    -Maharshi

    Dear,
    I didnt get your mean.
    Can you explain me the step.!
    -Maharshi

Maybe you are looking for

  • Trigger event even with Status change or status reason change

    Hi, My requirement is to trigger an event if there is a change in status reason. I am looking for the method which currently triggers an event if there is a change in status so that I can modify that. Any pointers please? If I was to do this with cha

  • GR Based IV Uncheck in Invoice Tab

    Dear All, the user checked the  GR based IV for few number of PO by mistake and did the GR(103 - GR blocked Stock). But user wants to post the IR before 105 as per business requiremnts now problem is that system is not allowing to uncheck the GR Base

  • Error in installing SBO1 2007

    Hi! I can't seem to get past installing of the server with the 2007A install files. I am getting errors and it will not create my common DB's at all...this is just one of the many I get: when it starts to publish the Common DB it states: "SetFieldVal

  • SAP Netweaver 7.3 Upgrade to SPS01

    Hi, I have installed SAP Netweaver 7.3 and now I need to upgrade to SPS01 (Required version for SAP Manufacturing Execution 6.0). Is SAP solution Manager the only way to do the upgrade? Br, Johan

  • Performance problem !! CPU 100% !!

    Hi all, Whe have an Weblogic application accessing Oracle Database 10gR2. We are having a high CPU Usage sometimes 100% for a long time (1 hour or more). The query that is consuming more CPU run in 2 seconds. I have 40 simultaneous connections on thi