1#!/usr/bin/perl
2# Copyright (c) 2006 Sampo Kellomaki (sampo@iki.fi), All Rights Reserved.
3# This is confidential unpublished proprietary source code of the author.
4# NO WARRANTY, not even implied warranties. Contains trade secrets.
5# Distribution prohibited unless authorized in writing. See file COPYING.
6# $Id: gen-cot-links.pl,v 1.2 2009-08-30 15:09:26 sampo Exp $
7# 30.9.2006, created --Sampo
8#
9# Generate symlinks in the /var/zxid/cot directory
10# Usage: cd /var/zxid/cot; ~/zxid/gen-cot-links.pl *
11
12undef $/;
13for $f (@ARGV) {
14    open F, "<$f" or die "Can't read($f): $!";
15    $x = <F>;
16    close F;
17    ($eid) = $x =~ /entityID="(.+?)"/;
18    if (!$eid) {
19	warn "Couldn't determine entityID for file($f). Skipped.";
20	next;
21    }
22    $eid =~ s%[/?]%_%g;
23    symlink $f, ".$eid";
24}
25
26#EOF
27