Thursday, 31 October 2013

BMC is in FW Transfer Mode

This is a message that I get when trying to remotely update the BIOS on Jefferson Pass systems equipped with Intel S2600JF mother boards and Intel E5-2690 Sandy Bridge CPUs. The solution is to do BMC cold reset using ipmi and wait for 30 seconds:
ipmitool mc reset cold
If IPMI kernel module happens not to be loaded, then load it with this command:
modprobe ipmi_devintf

Friday, 30 August 2013

How to compare two directory trees

When you want to see which files differ without further details:
diff -qr path/1/ path/2/
With a separate diff for each differing file:
diff -r path/1/ path/2/

Cheers.

Tuesday, 13 August 2013

How to find out the number of global variables in a binary

nm your-binary-file | grep '[0-9A-Fa-f]* [BCDGRS]' |cut -d ' ' -f 3 | grep -ve '__.*' | grep -v @@ | wc -l

Thursday, 30 May 2013

How to install a network printer at CERN under Ubuntu

Installing a driver at CERN is kind of a puzzle, unless you run Windows or SLC. Unfortunately there are no tutorials how to do that. This is why I came up with the following, somewhat hackerish, solution:
  1. Install packages libnet-ldap-perl and cups on your system using apt-get
  2. Download the lpadmincern RPM package.
  3. Unpack it.
  4. Replace inside lpadmincern.pl
    my $cupsc='/sbin/service cups reload';
    with
    my $cupsc='/usr/sbin/service cups reload';
  5. Replace
  6. $command="LC_ALL=C /usr/sbin/lpadmin -p $prt->{printerName} -L \"$prt->{location}\" -D \"$prt->{description}\" -v $uri $duplex $media -o printer-is-shared=false -E";
    with
    $command="LC_ALL=C /usr/sbin/lpadmin -p $prt->{printerName} -L \"$prt->{location}\" -P $prt->{ppdfile} -D \"$prt->{description}\" -v $uri $duplex $media -o printer-is-shared=false -E";
    Apparently this got replaced in the meanwhile.
  7. install libnet-ldap-perl
  8. Find your desired printer at CERN printing service
  9. Move the whole directory to /usr/share/lpadmincern, otherwise it would complain about a missing directory.
  10. Run
    perl lpadmincern.pl --add [your-printer-name-here]

How to check number of cores per CPU

echo $(($((`cat /proc/cpuinfo | grep 'processor' | sort -n | wc -l`))/$((`cat /proc/cpuinfo | grep "physical id" | sort -n | uniq | wc -l`))))

Monday, 18 February 2013

How to do a platform-independent path join in Java

Today I had to join a file path with its parent directory path. I could this simply by joining strings with "/", but this solution is not portable to non *nix systems. In Python I would write:
import os.path

parent = "a/b/c"
filename = "efg"
joined = os.path.join(parent, filename)
But what is Java equivalent? It turns out that the best way is to use java.io.File. One can do:
File parent = new File("a/b/c");
File file = new File("efg");
String joined = new File(parent, file).getPath();
The last line is to go back to String world, but possibly you don't have to.