Jul 24, 2007

First Time with Mono

vi a.cs:
using System;
using Mono.Unix;

public class Foo {
public static void Main (string[] args) {
foreach (UnixDriveInfo d in UnixDriveInfo.GetDrives ()) {

Console.WriteLine(String.Format("drive {0} available {1}",
d.Name, d.AvailableFreeSpace));

}
}
}
And then:
mjolnir:~ # mcs -r:Mono.Posix a.cs
mjolnir:~ # mono ./a.exe
drive / available 1136402432
drive /big available 22027657216
drive /proc available 0
drive /sys available 0
drive /sys/kernel/debug available 0
drive /proc/bus/usb available 0
drive /dev/pts available 0
drive /media/floppy available 1136402432
That did the trick in figuring out why rug thought it did not have enough disk space to install updates. (Answer: the cache-directory must have an entry in fstab; just mounting it is not enough.)
Before you ask, this does not mean that I'm rewriting all my shell scripts to Mono. I'm just happy to have passed this unknown territory successfully.

No comments: