Category Archives: Development Environment

Command line PuTTY

Just stumbled upon a new (to me) tool named Plink. Plink is a command-line interface to the PuTTY back ends and can for example be used when writing batch scripts in Windows.

For example the following one-liner could be used to start a script on a remote machine:

plink username@192.168.2.10 -pw password /folder/script.sh 

Plink can be downloaded from the regular PuTTY download page.

Regular expressions in notepad++

One of the first tools I always download when I’m face with a new Windows computer is notepad++. This clean and simple, yet very powerful, text editor is in my opinion an indispensible tool when working on a windows computer.

Except for the very useful “Find in Files” feature, which I’ve found to be light-years better than Windows’ built-in search feature, the regular expressions-type search (and replace) feature is also very useful.

Here’s an example on how to use this powerful feature, as I always tend to forget the exact syntax:

If I want to replace each line starting with either “#” or “;” with an empty line, or to completely remove the line, here’s how to do it:

Find:
^[#;].*

Replace:
(leave this emtpy.)

The ^ indicates the start of a line, the [#;] is a character class to match either # or ;, and .* matches anything else in the line.

In versions of Notepad++ before 6.0, you won’t be able to actually remove the lines due to a limitation in its regex engine; the replacement results in blank lines for each line matched. In other words, this:

# foo
; bar
statement;

Will turn into:

statement;

However, the replacement will work in Notepad++ 6.0 if you add \r, \n or \r\n to the end of the pattern, depending on which line ending your file is using, resulting in:
statement;

Be sure to select “Search Mode” -> “Regular Expression”

For example ^[#;].*\r\n in “Find what” and “” in Replace with will remove the entire line if it starts with # or ;!!

Simplified compiling

During my years as an embedded software consultant I’ve spent my fair share of time in projects with enormous build systems, outputting 1000’s of lines of messages when being built. The chance of spotting what could potentially be hazardous compiler warnings and remarks are then slim to nothing.

Of course, should I have a compiler that supports it, I could always turn on the gcc “-Werror” flag, treat all warnings as errors and then go about and fix all of these. However, sometimes that may not be a viable option, or perhaps I’d just like to get an overview of all warnings and solve them when time so permits.

The other day a colleague of mine introduced me to the simple, yet clever, tool “hilite”. This tiny piece of software will highlight anything printed to stderr, making it the perfect tool to use with your Linux/Unix-based build environment of choice.

Running a build with hilite, anything printed to stderr by the compiler, such as errors, warnings and remarks, will show up with bold red text on my screen – making these messages so much easier to spot.

Hilite can be found on sourceforge at the hilite page.

Finding the escape character

I find myself working in different terminal environments with different types of targets, something that sometimes gives me problems when trying to leave the target environment – how do I make that Escape character?

More often than not, I have opened a telnet session towards a target and has been greeted with the following message:

“Escape character is ‘^]’.”

I have found at least two different ways of making this escape character, depending on the environment I’m working in:

  • Ctrl+5
  • Alt+9
  • When I find more weird ways of producing this escape character, this blog post shall be updated.

    Diff labels in ClearCase

    Many customers seem to be using the ClearCase revision control system. While ClearCase is very powerful and useful in many ways, I have struggled to find a simple command to show the difference between two labels, i.e. which files that have been change between the application of these two labels.

    I have finally found how this is done:

    cleartool find -all -element ‘{lbtype_sub(LABEL1) && lbtype_sub(LABEL2)}’ -ver ‘{lbtype(LABEL1) && ! lbtype(LABEL2)}’ -nxname -print

    Just replace LABEL1 and LABEL2 with the labels of choice, and off you go. This will only show files which have both labels, files recently created that only has one of the labels on them will not be found – however since the above command would should the verified folder (where the file was added) those files are easilly spotted as well.

    Have your Makefile upload built binary to a target

    A colleague of mine introduced me to this really handy pice of command line software that has helped me in my daily work since then: curl.

    By simply adding a few extra lines to the end of my final rule of the Makefile I’m currently using I can now have the newly built binary automatically uploaded to a any folder on an target board of my liking, without having to do all these steps myself:


    # Build finaly binary. If "IP" is defined on command line, upload
    # built binary using curl.
    $(TARGET_NAME).out : ...
    ...
    ifdef IP
    curl -T $(TARGET_NAME).out ftp://x:x@$(IP)/c/bin/
    endif

    Simly add the IP address to use when invoking the Makefile, and you’re all set:


    $ make IP=172.31.90.216