Gilles Scokart wrote:
Unfortunately, I think that detecting that you are offline or online is
something quiet difficult.  So the user will have to pass some information
in his ant command line.


the big problem is deciding if a system is offline. I've lots of low level win32 stuff related to network state and while you can be 100% sure you are offline when there is no lan or modem, the presence of any of those things (or a WLAN, or an ipaddr outside the 169.* range) does not mean that you are online. If you cannot reliably tell WTF is going on in C++, you don't stand a chance in java. Hitting remote sites is the only way to be sure.


Ant1.7 has an IsReachable condition that does a ping, which wont go through firewalls. If you want to check a remote http server, then GET is all you have

How Ant does it:

  <target name="probe-offline">
    <condition property="offline">
      <or>
        <isset property="offline"/>
        <not>
          <http url="http://www.apache.org/"/>
        </not>
      </or>
    </condition>
    <echo level="verbose"> offline=${offline}</echo>
  </target>


-steve

Reply via email to