How to access OS environment and TCP/IP environment

I'm trying to find a way to access the operating systems commands (I've already figured out how to determine which Windows or which Unix or which Linux I'm in) and TCP/IP commands. In REXX, for example, it's ADDRESS CMD but I don't even have a clue as to what the class would be in Java. Can somebody help, please?
The two kinds of things I'd like to be able to do is issue commands written in whatever language for the environment where the Java program is executing and have the output from these commands come back as a string or series of strings which can then be parsed by the parser we've written for each of the environments we need to deal with (since the same command sometimes results in a different return, depending on the environment where it's running).
For the TCP/IP commands, I'd like to be able to do something like
tcp_ipCommands("ping","www.sun.com");
or
tcp_ipCommands("ping www.sun.com");
depending on how I write it, of course.
Thanks for any light anybody can shed on how to do this.
virginia

Have a Pinger. I can't remember where I stole it from and its from an older API with some deprecated methods. I recall making some 'cosmetic' changes to it at the time and I tested it, so it does work. I've also indicated 2 of the deprecations in the comments.
import java.applet.*;
import java.awt.*;
import java.net.*;
import java.lang.Thread;
// The Pinger object measures network latency by sending a packet
// to the UDP Echo Port (Port 7) and timing how long it takes.
// We use this port instead of ICMP because I would have to
// use native methods in order to produce ICMP packets.
class Pinger implements Runnable{
   static final int echoPort = 7;
   static final int maxPingTime = 3000; // Milliseconds
   static final int pingPollInterval = 100; // Milliseconds
   DatagramSocket socket;
   InetAddress fromIP;
   long sendTime;
   long timeMeasured;
   Thread timeOutMonitor;
   Thread pingListenThread;
   byte packetNumber = 0;
public Pinger(InetAddress pingee){
   fromIP = pingee;
// If needed, start a listener thread to notice the reply.
// then we send out a brief message to the echo port.
// Since the Java thread model does not allow one thread to break
// another one out of a wait, we sleep for brief intervals, waking
// up periodically to see if the reply has come in yet.
public long doPing() {
   byte[] msg = new byte[1];
   msg[0] = ++packetNumber;
   timeMeasured = -1;
      if(socket == null) try {
         socket = new DatagramSocket();
      catch (Exception e) {return(0);}
      if(pingListenThread == null) {
         pingListenThread = new Thread(this);
         pingListenThread.start();
   DatagramPacket packet = new DatagramPacket(msg,msg.length,fromIP,echoPort);
   sendTime = System.currentTimeMillis();
   long timeLimit = sendTime + maxPingTime;
      try {
         socket.send(packet);
            while (System.currentTimeMillis() < timeLimit) {
               Thread.sleep(pingPollInterval);
                  if(timeMeasured != -1) // reply has been noticed, so return result.
            return(timeMeasured);
      catch (Exception e) {};
      return(timeMeasured); // return what is probably -1.
// Run method for the listener thread
public void run() {
byte[] repBuf = new byte[1];
DatagramPacket reply = new DatagramPacket(repBuf,repBuf.length);
   try {
      while (true) {
      socket.receive(reply);
         if(repBuf[0] == packetNumber) {
             timeMeasured = System.currentTimeMillis() - sendTime;
             pingListenThread = null;
             return;
   catch (Exception e) {
      pingListenThread = null; return;
// Clean up any dangling listener thread and release the socket.
public void stop() {
    if(pingListenThread != null) {
        pingListenThread.stop();
        pingListenThread = null;
    socket.close();
    socket = null;
public class PingDisplay extends Applet {
   Pinger ping;
   TextField timeDisplay;
   String fromHost;
   Button refreshButton;
public void init(){
   try {
      fromHost = this.getCodeBase().getHost();
      // Alternative for testing on unrestricted browsers.
      // fromHost = "www.3dcom.com";
      ping = new Pinger(InetAddress.getByName(fromHost));
      timeDisplay = new TextField("Waiting");
      timeDisplay.setEditable(false);
      this.setLayout(new BorderLayout());
      this.add("Center",timeDisplay);
      refreshButton = new Button("Ping");
      refreshButton.resize(40,20);
      this.add("East",refreshButton);
   catch (Exception e) {}
public void start(){
   super.start();
   displayPing();
public void stop(){
   super.stop();
   ping.stop(); // Thread.stop() is depricated but it still works
void displayPing() {
   timeDisplay.setText("Pinging: " + fromHost); // let user know test underway
   long echoTime = ping.doPing(); // conduct actual test
      if(echoTime == -1) // check timeout status
         timeDisplay.setText(fromHost + " timed out.");
      else // display time in button
         timeDisplay.setText("Latency to " + fromHost + ": " + Long.toString(echoTime) + " ms.");
// When "Ping" button pressed, rerun and redisplay.
// Method also depricated here
public boolean action(Event e, Object what) {
   if((e.target == refreshButton) && (e.id == Event.ACTION_EVENT)) {
      displayPing();
      return (true);
   return(false);
}

Similar Messages

  • How to access sort direction and filter value of columns?  Can I catch the 'filtered' or 'sorted' event?

    We have some columns being added to a table.  We have set the sortProperty and the filterProperty on each of our columns.
    This allows us to both filter and sort.
    We want to be able to access the columns filter value and sort value after the fact.  Can we access the table and then the columns and then a columns properties to find these two items?  How can I access the sort direction and filter value of columns?
    We would also like to store the filter value and the sort direction, and re-apply them to the grid if they have been set in the past.  How can we dynamically set the filter value and sort direction of a column?
    Can I catch or view the 'filtered' or 'sorted' event?  We would like to look at the event that occurs when someone sorts or filters a column.  Where can I see this event or where can i tie into it, without overwriting the base function?

    Hey everyone,
    Just wanted to share how I implemented this:
    Attach a sort event handler to table - statusReportTable.attachSort(SortEventHandler);
    In this event handler, grab the sort order and sorted column name then set cookies with this info
    function SortEventHandler(eventData)
        var sortOrder = eventData.mParameters.sortOrder;
        var columnName = eventData.mParameters.column.mProperties.sortProperty;
        SetCookie(sortDirectionCookieName, sortOrder, tenYears);
        SetCookie(sortedColumnCookieName, columnName, tenYears);
    Added sortProperty and filterProperty to each column definition:
    sortProperty: "ColName", filterProperty: "ColName",
    When i fill the grid with data, i check my cookies to see if a value exists, and if so we apply this sort:
    function FindAndSortColumnByName(columnName, sortDirection (true or false))
        var columns = sap.ui.getCore().byId('statusReportTable').getColumns();
        var columnCount = columns.length;
        for(var i = 0; i < columnCount; i ++)
            if(columns[i].mProperties.sortProperty == columnName)
                columns[i].sort(sortDirection);

  • Entity Framework - Code First - Migration - How to access SQL Server and Oracle using the same context?

    Hello,
    I use Entity Framework code first approach.
    My project is working fine with SQL Server. But, I want to access Oracle too. I want to switch SQL Server and Oracle in run time.
    I am able to access Oracle using "Oracle.ManagedDataAccess.EntityFramework.dl" in a new project.
    But, Is this possible to access SQL Server and Oracle in the same project.
    Thanks,
    Murugan

    This should be possible with a Code-First workflow.  In Code-First the database mapping layer is generated at runtime.
    David
    David http://blogs.msdn.com/b/dbrowne/

  • How to access the jpanel and other components on click of a button

    hi ,
    need help,how to access the components of a frame onclick of a button ,if the actionPerformed() is written in a seperate class.
    in my code
    button.addActionListener(new Xyz());
    Xyz is implementing the ActionListener.
    in actionPerformed() i want to access the components in the frame.
    thanks.

    public class Xyz implements ActionListener{
      JFrame frame;
      Component[] comps;
      public Xyz(JFrame f){
        frame = f;
        comps = frame.getContentPane().getComponents();
      public void actionPerformed(ActionEvent e){
        // access elements in comps array
    button.addActionListener(new Xyz(this)); // if 'this' is a JFrame in question

  • How to access mobile camera and address book using j2me?

    I m using sun java wireless toolkit 2.5 beta and jdk1.5
    how can i access my mobile camera using j2me ?
    please give some example codes and links .....
    reply as soon as possible.!!!!

    Try this. Hope it help
    try
    Player m_player;
    m_player = Manager.createPlayer("capture://video");
    m_player.realize();
    m_vc = (VideoControl)m_player.getControl("VideoControl");
    m_vc.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);
    m_vc.setDisplayLocation(0, 0);
    m_vc.setDisplayFullScreen(true);
    m_player.start();
    m_vc.setVisible(true);
    catch ( IOException io )
    catch ( MediaException mx)
    Message was edited by:
    RiekeyLee

  • Printer - how to access defaultprinter fonts and loaded fonts in one job ( ie Arial 15 / etc )

    We have a file that contains font definitions that get loaded to the printer.
    These show on our PCL font list as "permanent soft fonts",
    and we access them by their font id number. If we just use the fonts that we loaded,
    our print step ( print layout/etc) is ok. If we try to access a font that exists
    on the printer, say Arial, which has both an escape sequence and an
    "internal xx" number, our print layout (grid), gets shifted to the right.
    We access the Arial font by : 
       esc%12345X and then the escape sequence for Arial font
    1. is there a way to refer to Arial ( or other printer default font )
        while still in PCL mode using our loaded fonts ( by font id ) ?
    2. should we add Arial to our font load file ?
        if yes, how do we do that ?
     any help is appreciated, thank you 

    A friendly soul on ubuntuforums pointed out to me, that the wireless configuration is only necessary when the printer is NOT connected to a (W)LAN. So all I really had to do was to configure the printer in the CUPS administation page, and it worked. Problem solved. Silly me.

  • I have created another user on our iMac but cannot figure out how to access aperture, excel and other purchased applications on the new desk top

    I have created an additional user on our iMac and have tried to set up file share but nothing happens.  I have an empty desktop and only the applications that came with the computer appear.  I'd like to have access to the others that we've purchased... Aperture, excel, etc.  I've followed the instructions for file sharing but I must be missing something. 
    Thanks for any assistance.

    Rebecca1952,
    You are over complicating things.  File sharing has nothing to do with what applications that each user has access to.
    To me it sounds like you just need some basic help getting the applications that you need onto your dock.
    Try this:
    Login to you new user account
    Click on an empty part of your desktop
    Click on the "Go" menu and select "Applications"
    A Finder window should open showing ALL of the applications on the Mac.
    Double-click one of them that you will use frequently (e.g. Excel)
    Once it is up and running you should see it's icon down on your dock.
    Right-click that icon on the dock, then select "Options", and "Keep in Dock"
    Once you have added each application to the dock in this manner, then it will remain there even after you quit the application.
    For one more expert way to launch any application on your mac quickly, try this:
    Hold the [command] key and hit the [spacebar] (this will start a Spotlight search)
    Start typing the name of the application you want to run (e.g. "Aperture")
    Once you see "Aperture" selected, simply hit the [return] key and Aperture will launch
    Hope this solves you problem.

  • How to access %programfiles% environment variable in XML

    Hi
    I am trying to install BEA JRockit 1.4.2 JVM silently and I need help in modifying the silent.xml file. Typically, in batch files, one would use the environment variable %programfiles% to install to the system's program files directory. However I want to do this within the silent install file that BEA recommends. The line that I want to modify is:
    <data-value name="USER_INSTALL_DIR" value="D:\Program Files\Java\jrockit-24.5.0-j2sdk1.4.2_08" />
    To something more like:
    <data-value name="USER_INSTALL_DIR" value="<b>${programfiles}</b>\Java\jrockit-24.5.0-j2sdk1.4.2_08" />
    However this does not work for me. Any help is greatly appreciated.
    Thanks,
    Jaaved

    Hi Jaared,
    You will have to create an additional wrapper that generates the silent.xml
    of your choice with a value of USER_INSTALL_DIR based on the value of the
    %PROGRAMFILES% environment variable. The value of USER_INSTALL_DIR is
    currently interpreted literally and there does not exist any support for
    expansion of environment variables in it. Based on your question we might
    consider this feature for a future release though.
    Regards
    /Robert
    <Jaaved Mohammed> wrote in message news:[email protected]..
    Hi
    I am trying to install BEA JRockit 1.4.2 JVM silently and I need help in
    modifying the silent.xml file. Typically, in batch files, one would use
    the environment variable %programfiles% to install to the system's program
    files directory. However I want to do this within the silent install file
    that BEA recommends. The line that I want to modify is:
    <data-value name="USER_INSTALL_DIR" value="D:\Program
    Files\Java\jrockit-24.5.0-j2sdk1.4.2_08" />
    To something more like:
    <data-value name="USER_INSTALL_DIR"
    value="<b>${programfiles}</b>\Java\jrockit-24.5.0-j2sdk1.4.2_08" />
    However this does not work for me. Any help is greatly appreciated.
    Thanks,
    Jaaved

  • How to access the currentPage and currentNode Objects in a Sling Servlet

    I have a requirement to write a Sling Servlet instead of regular CQ5 JSP
    In a standard CQ5 JSP it's easy to use the currentPage and currentNode objects, as they are automatically added by the default includes
    <%@include file="/libs/foundation/global.jsp"%>
    <h2>currentPage</h2>
    Title: <%= currentPage.getTitle() %><br />
    Name: <%= currentPage.getName() %><br />
    Path: <%= currentPage.getPath() %><br />
    Depth: <%= currentPage.getDepth() %><br />
    <h2>currentNode</h2>
    Title: <%= currentNode.getProperty("jcr:title").getString() %><br />
    Name: <%= currentNode.getName() %><br />
    Path: <%= currentNode.getPath() %><br />
    Depth: <%= currentNode.getDepth() %><br />   
    </div>
    I would like to know how to do this in a sling servlet, and be able to use the currentNode and currentPage objects.
    Does anyone have any code samples they would like to share??
    Thanks
    Tyrone

    currentPage - request.getResource().adaptTo(Page.class)
    currentNode - request.getResource().adaptTo(Node.class)

  • How to access the library and properties in captivate 8

    hello ...i should see the library and the properties buttons in the upper right corner of my screen...
    but i do not....please advise....i need to know how to do that...

    Please check if you get the same buttons for library and properties as mentioned in the screen shot below.
    Please click on the library or properties as indicated in the screenshot.
    If you still face any concerns please post your screen shot how exactly you are getting the library and properties button in Captivate.
    Regards,
    Rajeev.

  • How to  access my txt and phone voice messages online

    Hi, I am out of country but didn't purcahse Global services. My phone is on airplane mode. I have samsung note 2. I have wifi access. Is there anyway for me to read my voice mail and text messages online?
    Thanks

        Happy travels, jhsi! Text message content is not available online! You may check your voicemail messages if the line is not suspended by dialing your mobile number, hitting #, and enter your voicemail password.
    Thank you,
    LenaA_VZW
    Follow us on Twitter @VZWSupport

  • How to access TestStand Event and variables from external application?

    Hi all
    The test system was built by TestStand, now there is a new requirement to filter the test report without change the sequence file. The task must be done without any impact to previous software system, so I decide to write a tool by VC++.
    My idea is to deal with the reports after every UUT loop, but I need to monitor the UUT loop status by VC++, if an unit is tested, pass or fail, raise a event and pass to VC++ application. In a word, I would like to access TestStand internal event and variables.
    Anyone has ideal on this case? ActiveX or something.
    thanks .
    Rexxar
    *The best Chinese farmer*

    paulbin,
    While sharing variables via COM or DCOM is certaintly possible, I don't think you need to go down that route.  I think that there is probably an easier way to limit your report.  In your Configuration menu, under the Report Options item, there is a field at the top that will allow you to filter what steps go into your report.
    This will not affect any sequence file you may have already created, all it does is change a few options in the ReportOptions.ini file in the <TestStand>\cfg directory.
    This is a much simpler option than trying to write a program to interface with a running TestStand engine.
    Josh W.
    Certified TestStand Architect
    Formerly blue

  • How to access Anniversary date and birthdate from addressbook in cococa?

    Hello,
    I am not able to read and Write anniversary date and birthdate in address book.
    can anyone please tell me how can i do it?
    it is very important for me to know.because I have setted all other properties.
    i am not able to set and retrive these properties only.
    Thank You..
    xmax.

    Like this ...
    ABAddressBook *AB = [ABAddressBook sharedAddressBook];
    ABPerson* me = [AB me];
    [me setValue:[NSDate dateWithNaturalLanguageString:@"2004-08-28"] forProperty:kABBirthdayProperty];
    [AB save];
    Hope this helps.
    Eric

  • How to access output 13 and higher in AU Lab?

    Hey all,
    I'm trying to get AU Lab working in a configuration with 17 stereo outputs (or 34 mono). I'm having a problem in that when it comes to assigning the output from a generator channel strip it only shows outputs 1-12 (next to the meters). I can't find any way to make the rest of the outputs appear, so I can't assign the generators to those outputs.
    Anyone have any idea how to do so?
    TIA,
    Martin

    Hey all,
    I'm trying to get AU Lab working in a configuration with 17 stereo outputs (or 34 mono). I'm having a problem in that when it comes to assigning the output from a generator channel strip it only shows outputs 1-12 (next to the meters). I can't find any way to make the rest of the outputs appear, so I can't assign the generators to those outputs.
    Anyone have any idea how to do so?
    TIA,
    Martin

  • How to access Autocad2013 drawing and modify directly from c#?

    I want to open autocad 2013 from C# & open drawing file & modify it. how to send autocad command to autocad2013 directly from visual studio.

    Hi Kishor,
    AutoCAD is out of our support range, I think what you need is AutoCAD API for .NET. Please refer to the following link to see AutoCAD .NET Developer’s Guide.
    http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html?url=WS1a9193826455f5ff-e569a0121d1945c08-2024.htm,topicNumber=d0e52566.
    Regards,
    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.
    Click
    HERE to participate the survey.

Maybe you are looking for

  • Date Calculate difference between 2 days using DateField

    Hi, I have 2 dateFields on stage. I hav2 a text box ,which I want to display, the number of days difference, when I select datefield1 and then datefield2. The code I have is not working, can you please point me in the right direction ? I have done th

  • Vendor not intended for a puchasing org

    Hi Experts,    While creating a SC, We are getting the following error of "Vendor xxx not intended for a puchasing org  yyyyy". We are using the EBP3.0. I will appreciate your help. Thanks, J Kumar.

  • How to display html content in flex hero..

    i need to display html content using flex hero for balckberry playbook..i could not find a component for it..i have tried with spark text area by setting its html text property via MobileTextField. bt i need a webview to load html content to execute

  • Global variable for function in JSP?

    Hi, In my JSP file I have a variable (sName) which I would like to use in a function. Is that possible? Do I have to declare it differently? Many thanks Simone Here the code fragement: <jsp:useBean id="s" class="ServiceRegistryClient"></jsp:useBean>

  • Iphoto keeps crashing, even when starting with command-option,

    does anybody have an idea ???? tried the normal steps, with the disk permission, deleten plist, and tried twice to start with command-option... here is the crash-log.... thanx, magdonnellen Mac OS X Version 10.4.11 (Build 8S165) 2011-01-03 08:12:59 +