Much ado about scripting, Linux & Eclipse: card subject to change

Showing posts with label debug. Show all posts
Showing posts with label debug. Show all posts

2010-04-04

Cleaner Ant Build Logs: Get Rid of "Trying to override old definition of task"

If you use macros in Ant, you have probably seen clutter in your log such as

Trying to override old definition of task ...

Here's how to purge this garbage from your log and keep your build output cleaner.

  1. move your macros into a target such as <target name="init">
  2. have your main target(s) depend on the target that defines the macros
  3. call your macros

You can make your log even quieter with -q when running ant, eg., ant -f build.xml -q

Here's a complete example that will first self-bootstrap itself by downloading Ant-Contrib, define two ant macros, and produce very quiet output (unless debug=true):

<project default="run">
 <property name="COMMON_TOOLS" value="${java.io.tmpdir}" />
 <property name="debug" value="false"/>

 <target name="get.ant-contrib" unless="ant-contrib.jar.exists">
  <property name="ANTCONTRIB_MIRROR" value="http://downloads.sourceforge.net/ant-contrib/" />
  <get usetimestamp="true"
       dest="${COMMON_TOOLS}/ant-contrib-1.0b2-bin.zip"
       src="${ANTCONTRIB_MIRROR}/ant-contrib-1.0b2-bin.zip"
  />
  <touch file="${COMMON_TOOLS}/ant-contrib-1.0b2-bin.zip" />
  <mkdir dir="${java.io.tmpdir}/ant-contrib-1.0b2-bin.zip_" />
  <unzip src="${COMMON_TOOLS}/ant-contrib-1.0b2-bin.zip"
         dest="${java.io.tmpdir}/ant-contrib-1.0b2-bin.zip_"
         overwrite="true"
  />
  <copy file="${java.io.tmpdir}/ant-contrib-1.0b2-bin.zip_/ant-contrib/lib/ant-contrib.jar"
        tofile="${COMMON_TOOLS}/ant-contrib.jar"
        failonerror="true"
  />
  <delete dir="${java.io.tmpdir}/ant-contrib-1.0b2-bin.zip_" includeemptydirs="true" quiet="true" />
 </target>

 <target name="init">
  <available file="${COMMON_TOOLS}/ant-contrib.jar" type="file" property="ant-contrib.jar.exists" />
  <antcall target="get.ant-contrib" />

  <taskdef resource="net/sf/antcontrib/antlib.xml">
   <classpath>
    <pathelement location="${COMMON_TOOLS}/ant-contrib.jar" />
   </classpath>
  </taskdef>
  
  <macrodef name="debug">
   <text name="echo" />
   <sequential>
    <if>
     <and>
      <isset property="debug" />
      <istrue value="${debug}" />
     </and>
     <then>
      <echo message="@{echo}" />
     </then>
    </if>
   </sequential>
  </macrodef>

  <macrodef name="list.count">
   <attribute name="list" default="" />
   <sequential>
    <var name="count" value="" />
    <for param="listitem" list="@{list}" delimiter=", ">
     <sequential>
      <var name="count" value="${count}0" />
     </sequential>
    </for>
    <length property="list.count.return" string="${count}" />
   </sequential>
  </macrodef>
 </target>

 <target name="run" depends="init">
  <property name="list" value="foo bar baz"/>
  <list.count list="${list}" />
  <debug>For list [${list}], size = </debug>
  <echo>${list.count.return}</echo>
 </target>

</project>

2008-07-24

/usr/sbin/vpnc-connect: quick mode response rejected: (ISAKMP_N_INVALID_MESSAGE_ID)(9)

I've been using vpnc 0.3.3 and then 0.5.1 for about the last 3 years to connect to my VPN at work. This week, it stopped working.

/usr/sbin/vpnc-connect: quick mode response rejected:  (ISAKMP_N_INVALID_MESSAGE_ID)(9)
this means the concentrator did not like what we had to offer.
Possible reasons are:
 * concentrator configured to require a firewall
    this locks out even Cisco clients on any platform expect windows
    which is an obvious security improvment. There is no workaround (yet).
 * concentrator configured to require IP compression
    this is not yet supported by vpnc.
    Note: the Cisco Concentrator Documentation recommends against using
    compression, expect on low-bandwith (read: ISDN) links, because it
    uses much CPU-resources on the concentrator 

Did I call the help desk? No: Google to the rescue.

The fix? Well, this post got me in the right direction, and I updated my version of vpnc from 0.5.1r275-1 to 0.5.1r334-1 (apt-get update; apt-get install vpnc) using these repos... which didn't seem to help.

# Unstable Sid
deb http://http.us.debian.org/debian/ unstable main contrib non-free
# Unstable Sources
deb-src http://http.us.debian.org/debian/ unstable main contrib non-free

# sidux http://sidux.com/files/misc/sources.list
deb http://sidux.com/debian/ sid main contrib non-free firmware fix.main fix.contrib fix.non-free
deb-src http://sidux.com/debian/ sid main contrib non-free firmware fix.main fix.contrib fix.non-free

But the actual solution was to add this line to my .conf file:

Enable Single DES

And remove this:

Perfect Forward Secrecy nopfs

2007-08-23

PDT: PHP Debugging w/ Zend

Saw a post on dzone about setting up the Zend Debugger for use with PDT. It inspired me to finally try this out.

Installing PDT and Zend Debugger (client) is easy -- just add these two Update sites to your Eclipse and grab all the updates:

http://download.eclipse.org/tools/pdt/updates/
http://downloads.zend.com/pdt/

After restarting, you can do console php debugging as shown in in the above article. Very cool -- breakpoints & console work as expected, and you can step in/over/though code and see variables, just like with the JDT debugger for Java code.

Getting PHP web debugging to work took a little more effort. This is partly because of my eclipse.org sandbox setup, but also because I didn't RTFM properly. Also, I encountered an editor management bug which might be related to how Mylyn and the Auto-pin Tweaklet play together.

Anyway, after breaking with tradition ("hack first, ask questions later") and actually checking in a newsgroup for help, I found a link to Installing the Zend Debugger Server. Server installation was straightforward -- just grab the latest server code and unpack it into /opt or similar, and follow the steps in the install guide / README.

Then I had to simply configure PDT a little...

... toggle my /etc/hosts file, and launch a project web page (ALT-SHIFT-D, W) to try it out.