diff options
author | cvsadm <cvsadm> | 2005-01-21 00:44:34 +0000 |
---|---|---|
committer | cvsadm <cvsadm> | 2005-01-21 00:44:34 +0000 |
commit | b2093e3016027d6b5cf06b3f91f30769bfc099e2 (patch) | |
tree | cf58939393a9032182c4fbc4441164a9456e82f8 /ldap/cm/newinst/replaceToken.pl | |
download | ds-b2093e3016027d6b5cf06b3f91f30769bfc099e2.tar.gz ds-b2093e3016027d6b5cf06b3f91f30769bfc099e2.tar.xz ds-b2093e3016027d6b5cf06b3f91f30769bfc099e2.zip |
Moving NSCP Directory Server from DirectoryBranch to TRUNK, initial drop. (foxworth)ldapserver7x
Diffstat (limited to 'ldap/cm/newinst/replaceToken.pl')
-rw-r--r-- | ldap/cm/newinst/replaceToken.pl | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/ldap/cm/newinst/replaceToken.pl b/ldap/cm/newinst/replaceToken.pl new file mode 100644 index 00000000..13265efe --- /dev/null +++ b/ldap/cm/newinst/replaceToken.pl @@ -0,0 +1,34 @@ +# +# BEGIN COPYRIGHT BLOCK +# Copyright 2001 Sun Microsystems, Inc. +# Portions copyright 1999, 2001-2003 Netscape Communications Corporation. +# All rights reserved. +# END COPYRIGHT BLOCK +# + +# The first argument is the file to edit +# The remaining arguments are pairs of values: the first value of the pair is +# the token to look for, and the second is the value to replace it with e.g. +# if the input file foo contains +# $NETSITE_ROOT/%%%PERL_RUNTIME%%% -w perlscript ... +# then running $(PERL) thisscript foo %%%PERL_RUNTIME%%% foo/bar/perl5 > output/foo +# will result in output/foo containing +# NETSITE_ROOT/foo/bar/perl5 -w perlscript ... + +($input, %tokens) = @ARGV; + +if (! $input) { + print STDERR "Usage: $ $0 <inputfilename> [token1 replace1] ... [tokenN replaceN]\n"; + exit 1; +} + +open(INPUT, $input) or die "Error: could not open file $input: $!"; + +while (<INPUT>) { + while (($key, $value) = each %tokens) { + s/$key/$value/g; + } + print; +} + +close INPUT; |