Home
TeamSite
update all DCRs
MattP
If I update my datacapture.cfg to include a text element with a default value, how do I force all of the existing DCRs to reflect the new item and default value?
It seems if I make a change to the datacapture.cfg and then edit an existing DCR, it inserts the items, but not the default value. If I create a new DCR from the updated Datacapture, it includes the items and the default value.
I have about 1200 files to update.
I thought I remember seeing a post about this.
Thanks in Advance
Matt
TS 5.5.2 sp3
Win 2K
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA
Find more posts tagged with
Comments
Migrateduser
If you need to update the DCRs and regenerate all, you probably need to write a script or something that updates the DCR files. or have the presentation template insert the default value if none is present in the DCR. If it is a required field and you only need the data to be defaulted the next time someone edits the file you can use formAPI to populate the default value if there is no value already in that field.
MattP
Interestingly, I don't need to regenerate. All I need to do is add 2 items with a default value, so that a callout could potentialy interact with it. The callout will handle the regeneration and submit (if it isn't locked, thanks for your earlier help)...
so I need to add
<item name="Americas">
<value>#</value>
</item>
<item name="Europe">
<value>#</value>
</item>
So in my Datacapture.cfg I have added...
<item name="Americas">
<label>Americas</label>
<text>
<default>#</default>
</text>
</item>
<item name="Europe">
<label>Europe</label>
<text>
<default>#</default>
</text>
</item>
I agree that I could write a script to run through every file and update it, but it seems like there should be a way to have the dcr validate against the datacapture and update.
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA
Migrateduser
I totally agree with you - when you access the DCR it should check what version of the DCT it was generated from and reapply the defaults for fields that have been added. But I think in this case the simplest solution without waiting for a feature request is to use FormAPI. Here's an example:
var item = IWDatacapture.getItem( "/SomeField" );
if ( item != null )
{
var value = item.getValue();
if ( value == null || value == "" || value == undefined )
{
item.setValue( "DefaultValue" );
}
}
In fact I always do this instead of inline or specifying a default value in the DCT, just so I don't have to maintain the values in multiple places. Unfortunately it has to be in JavaScript. I guess you could do a callServer and set it with a JSP or CGI.
MattP
Argh. The only issue there is the file needs to opened in order for it to run. I need to run through each DCR in a directory and add the item and value. ARGH. Seems like it should be pretty straight forward.
Thanks for the tips
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA
Migrateduser
I've attached a little bit of code that might help get you started. The first piece of code is called from a workflow and is used to replace a value in the dcr and submit it.
The second piece of code was something I used to search all the files.
Using both of these examples you should be able to create something useful. When you get it completed please be sure to share it with everyone.
#!e:\iw-home/iw-perl/bin/iwperl
######################################################################
# Copyright 2000, 2001 Interwoven, Inc.
# All Rights Reserved.
#=====================================================================
#
#
# Created by : Interwoven, Tad Aalgaard
# Modified by : Tad Aalgaard
######################################################################
use TeamSite::WFtask;
use TeamSite::WFworkflow;
use Mail::Mailer;
use Getopt::Long;
use TeamSite::Config;
use strict;
use File::Copy;
## begin Tad's code
use TeamSite::XMLparser;
## end Tad's code
my $VERSION = "5.0.1 Build 3687 REL Interwoven 20010719";
(my $iwhome = TeamSite::Config::iwgethome()) =~ tr|\\|/|;
(my $iwmount = TeamSite::Config::iwgetmount()) =~ tr|\\|/|;
#=====================================================================
# Set default values for command line options, then process any
# supplied arguments to replace the default values.
#=====================================================================
my($def_body) = "A task in job **** has been assigned to you.";
my($def_subj) = "Your approval has been requested on a PartnerPage document.";
my(%opts) = ('a' => undef, # attachement(s) [not-implemented]
'b' => undef, # body from file [overrides -m]
'c' => undef, # cc list
'f' => undef, # from [$task->GetOwner()]
'H' => 0, # HTML-mode [not implemented]
'h' => undef, # help
'm' => "$def_body",# body message [has default]
's' => "$def_subj",# subject [has default]
't' => undef, # to list [required!]
'u' => undef, # url base [not implemented]
'v' => undef, # version
);
GetOptions(\%opts, qw(h v b=s c=s@ f=s m=s s=s t=s@));
#=====================================================================
# For backwards compatibility - if the first argument passed in
# (after stripping away all flagged arguments) is not a series
# of digits (i.e. a jobid) - assume it is the name of the intended
# recipient and shift it off the ARGV array.
#=====================================================================
if (defined($ARGV[0]) && $ARGV[0] !~ /^\d+$/){
push(@{$opts{t}}, shift);
}
die("$0 v. $VERSION\n") if ($opts{v});
usage() if ($opts{h} || !defined($opts{t}));
#=====================================================================
# Read in site specific configuration information
#=====================================================================
my($iwcfg) = "$iwhome/bin/iwconfig iwsend_mail";
(my $maildomain = `$iwcfg maildomain`) =~ s/\n$//;
(my $mailserver = `$iwcfg mailserver`) =~ s/\n$//;
(my $use_mapping_file = `$iwcfg use_mapping_file`) =~ s/\n$//;
(my $email_mapping_file = `$iwcfg email_mapping_file`) =~ s/\n$//;
(my $debug_output = `$iwcfg debug_output`) =~ s/\n$//;
die("$0: Required configuration parameter missing.\n",
"\tPlease see documentation.\n")
if (!defined($maildomain) ||
!defined($mailserver) ||
!defined($use_mapping_file) ||
(!defined($email_mapping_file) && ($use_mapping_file eq 'true')));
#=====================================================================
# Define the other variables we need.
#=====================================================================
my($wfid, $taskid, $area) = (
@ARGV[0
..2]);
my($task) = new TeamSite::WFtask($taskid);
my $dcrCreatorName = $task->GetOwner();
my($job) = new TeamSite::WFworkflow($wfid);
$area = $task->GetArea() if (!$area);
my($jobname) = $job->GetName();
my($jobdesc) = $job->GetDescription();
my(
@workcomments)
;
$task->GetComments(\
@workcomments)
; #=# UGH - should just return a ref
my($def_body) = "A task in job $wfid has been assigned to you.";
my($body) = get_body();
$opts{f} = $opts{f} || $task->GetOwner();
my($url) = '';
#=====================================================================
# Do address conversions as necessary
#=====================================================================
$opts{t} = split_addresses($opts{t});
$opts{c} = split_addresses($opts{c});
#=====================================================================
# Construct date header
#=====================================================================
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year += 1900;
$mon = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[ $mon ];
$wday = (qw(Sun Mon Tue Wed Thu Fri Sat))[ $wday ];
my $date = "$wday $mday $mon $year $hour:$min:$sec GMT";
#=====================================================================
# Construct the email
#=====================================================================
my $mailer = new Mail::Mailer('smtp', Server => $mailserver);
my(%headers) = ('To' => $opts{t},
'Cc' => $opts{c},
'From' => $opts{f},
'Subject' => $opts{s},
'Date' => $date,
);
#=#================DEBUGGING
foreach my $k (sort(keys(%headers))){
if (ref($headers{$k}) eq "ARRAY"){
foreach my $e (@{$headers{$k}}){ debug("$k ==> $e"); }
}
else { debug("$k => $headers{$k}");}
}
#=#================DEBUGGING
my $temp="";
my $temp2="";
my $status="created";
my($message) = "";
##open OUT, ">e:\\iw-home\\wfdebug.txt";
$temp=$workcomments[-1];
splice (
@workcomments
, 1, 1) ; # this deleted the array
@workcomments=($temp)
;
if (
@workcomments){
foreach my $cmt_hash (reverse(
@workcomments))
{
$temp2=$cmt_hash->{user};
if($temp2 ne "SYSTEM"){
$message= join("",
$cmt_hash->{user},
" started approval proccess on ", $cmt_hash->{date},
"\n",
" Comments: ", $cmt_hash->{body},
"\n");
}
}
}
my(
@iw_files)
;
map { push(
@iw_files
, "$url$_"); } $task->GetFiles();
if (
@iw_files){
my $file;
my
@files=()
;
my
@files
= $task->GetFiles();
foreach $file (
@files){
$file =~ s|/|\\|g;
if ( $file =~ m|^templatedata.*| ){
my $dcrname = $file;
$dcrname =~ s|.*\\||g; # find the dcr name (without the path)
my $tplpath = $file;
$tplpath =~ s|\\data\\.*||g; #strip off /data/dcr from path
$tplpath = $area . "\\" . $tplpath . "\\presentation\\xml.tpl";
my $xmlpath = $file;
$xmlpath =~ s|\\data\\.*||g; #strip off /data/dcr from path
$xmlpath =~ s|templatedata\\||g; #strip off /data/dcr from path
$xmlpath =~ s|.*\\||g;
my $dynamopath = $xmlpath;
my $dynamopath2 = $xmlpath;
my $xmlpath1 = "\\xml_data\\" .$xmlpath . "\\" . $dcrname . ".xml";
$xmlpath = $area . "\\xml_data\\" .$xmlpath . "\\" . $dcrname . ".xml";
my $dcrpath = $file;
$dcrpath = $area . "\\" . $file;
#print OUT "sss \n";
my $fileName='';
my $approvalTrail='';
my $dcr = "y:" . $dcrpath;
### Read in the DCR for XML parsing.
my $xml;
if (! open DCR, "$dcr") { next; }
while (<DCR>) {
$xml .= $_;
}
close DCR;
my $parser = TeamSite::XMLparser->new();
my $rootnode = '';
$rootnode = $parser->parse($xml);
if (defined $rootnode)
{
$approvalTrail = $rootnode->value("approvalTrail");
$fileName = $rootnode->value("fileName");
#my
@reps
= "";
my
@reps
= $rootnode->list("fileData");
#print OUT "reps :
@reps\n"
;
if (
@reps
== "")
{
#$fileName = "dd";
# print OUT "a : $fileName\n";
if ($fileName ne '')
{
my $attachmentpath = "e:\\partnerpagedev\\repositories\\" . $dynamopath2 . $fileName;
$attachmentpath =~ s|/|\\|g;
my $attachmentpath2 = "y:" . $area . $fileName;
$attachmentpath2=~ s/\//\\/g;
# print OUT "attachmentpath : $attachmentpath\n";
# print OUT "attachmentpath2 : $attachmentpath2\n";
$fileName =~ s/\//\\/g;
my $attachattachments = "e:\\iw-home\\bin\\iwaddtaskfile.exe -s nt16 " . $taskid . " " . "$fileName" . " Attachment";
qx/$attachattachments/; # finally execute the iwgen command
# print OUT "attachattachments : $attachattachments\n";
$_=$fileName;
$_ =~ s/\\/\\\\/g;
$_ =~ s|\\attachments\\||g;
$_="attachments" . $_;
#print OUT "empty : $_\n";
my $dir1="";
my $dir ="";
my $dir3="";
my
@details=split
/\\\\/, $_;
foreach (
@details)
{
print "$_\n";
$dir1=$dir1 . "\\\\" . $_;
#print "$dir1\n";
# print "$dir\n";
my $dir3="mkdir " . $dir;
# print OUT "dir3 : $dir3\n";
qx/$dir3/;
$dir = "e:\\\\partnerpagedev\\\\repositories\\\\" . $dynamopath2 . $dir1;
}
copy ($attachmentpath2,$attachmentpath);
}
}
else
{
for my $rep (
@reps)
{
$fileName = $rep->value("fileName");
#print OUT "fileName1 : $fileName";
####
if ($fileName ne '')
{
my $attachmentpath = "e:\\partnerpagedev\\repositories\\" . $dynamopath2 . $fileName;
$attachmentpath =~ s|/|\\|g;
my $attachmentpath2 = "y:" . $area . $fileName;
$attachmentpath2=~ s/\//\\/g;
# print OUT "attachmentpath : $attachmentpath\n";
# print OUT "attachmentpath2 : $attachmentpath2\n";
copy ($attachmentpath2,$attachmentpath);
$fileName =~ s/\//\\/g;
my $attachattachments = "e:\\iw-home\\bin\\iwaddtaskfile.exe -s nt16 " . $taskid . " " . "$fileName" . " Attachment";
qx/$attachattachments/; # finally execute the iwgen command
# print OUT "attachattachments : $attachattachments\n";
$_=$fileName;
$_ =~ s/\\/\\\\/g;
$_ =~ s|\\attachments\\||g;
$_="attachments" . $_;
# print OUT "empty : $_\n";
my $dir1="";
my $dir ="";
my $dir3="";
my
@details=split
/\\\\/, $_;
foreach (
@details)
{
print "$_\n";
$dir1=$dir1 . "\\\\" . $_;
#print "$dir1\n";
# print "$dir\n";
my $dir3="mkdir " . $dir;
# print OUT "dir3 : $dir3\n";
qx/$dir3/;
$dir = "e:\\\\partnerpagedev\\\\repositories\\\\" . $dynamopath2 . $dir1;
}
copy ($attachmentpath2,$attachmentpath);
}
###
}
@}#if statement that checks if
@Reps
exists
}
my $message2 = $approvalTrail . $message;
$message2 = "<value>" . $message2 . "</value>";
close DCR;
### Substitute the old field values with the new one.
if ($status eq "created") {
$xml =~ s|name="approvalTrail">(.*?)</value>|name="approvalTrail">$message2|s;
### Write the new DCR back out.
open DCR, ">$dcr";
print DCR $xml;
close DCR;
}
### Generate an XML file using the DCR and Presentation template.
my $PATH="e:\\iw-home\\bin;$ENV{PATH};y:\\;h:\\";
$ENV{PATH} = $PATH;
#chdir("y:\\default\\main\\PartnerPageDev\\WORKAREA\\Sales");
my $stuff = $area;
$stuff =~ s|\\|\\\\|g;
$stuff = "y:\\" . $stuff;
chdir($stuff);
# print OUT "stuff : $stuff\n";
my $generatexml = "e:\\iw-home\\bin\\iwgen -t " . $tplpath . " -r " . $dcrpath . " " . $xmlpath;
qx/$generatexml/; # finally execute the iwgen command
# print OUT "generatexml : $generatexml\n";
$dynamopath = "e:\\partnerpagedev\\repositories\\" . $dynamopath . "\\xml\\" . $dcrname .".xml";
$xmlpath ="y:" . $xmlpath;
# print OUT "dynamopath : $dynamopath\n";
# print OUT "xmlpath : $xmlpath\n";
copy ($xmlpath,$dynamopath);
## must use the '$_' in be line below
#my $dir="mkdir e:\\partnerpagedev\\repositories\\service\\attachments\\service\\tech_tips\\artista\\junk";
#qx/$dir/;
##$_="service\\attachments\\service\\tech_tips\\artista\\junk";
my $dir1="";
my $dir ="";
my $dir3="";
###my
@details=split
/\\/, $_;
###foreach (
@details)
{
#print "$_\n";
### $dir1=$dir1 . "\\" . $_;
#print "$dir1\n";
### $dir = "e:\\partnerpagedev\\repositories" . $dir1;
# print "$dir\n";
### my $dir3="mkdir " . $dir;
### qx/$dir3/;
###}
############
my $attachxml = "e:\\iw-home\\bin\\iwaddtaskfile.exe -s nt16 " . $taskid . " " . $xmlpath1 . " XML-Generated";
qx/$attachxml/; # finally execute the iwgen command
$message2 = '';
$approvalTrail='';
$xml = '';
$dcr = '';
$fileName = '';
}
}##end of foreach
#print OUT "done\n";
}
$task->CallBack(0, "Started");
######################################################################
# SUBROUTINES
######################################################################
sub usage{
die("Usage: $0 [-h|-v]\n\n",
"\t-h\t(help - this output - only)\n",
"\t-v\t(version information - only)\n\n",
"Usage: $0 [flags] <jobid> <taskid> <areavpath>\n\n",
" Flags:\n",
"\t-b file\t(message body)\n",
"\t-c arg [-c arg ...]\t(Cc: recipent(s))\n",
"\t-c arg,arg[,...]\t(Cc: recipient(s))\n",
"\t-f arg\t(From: recipient)\n",
"\t\t[Task Owner]\n",
"\t-m arg\t(Message body text [inlined])\n",
"\t\t[default: '$def_body']\n",
"\t-s arg\t(Subject string)\n",
"\t\t[default: '$def_subj']\n",
"\t-t arg [-r arg ...]\t(To: recipient(s))\n\n",
"\t-t arg,arg[,...]\t(To: recipient(s))\n",
"<jobid>, <taskid>, and <areavpath> added implicitly ",
"by workflow engine.\n");
}
#=====================================================================
# Start with [assumed] default (could be overridden by -m flag) then
# check for use of -b flag and attempt to read in specified file.
# If a failure occurs trying to read in the file - go with the default.
#=====================================================================
sub get_body{
(my $body = $opts{m}) =~ s/****/$wfid/; # default
if (defined($opts{b})){
if (open(IN, "<$opts{b}")){
local($/) = undef;
$body = <IN>;
close(IN);
}
else {
debug("$0 '$opts{b}' ($!)\n");
}
}
return("Your approval has been requested on a PartnerPage document. See the \"description\" field below for the document name. Please log into TeamSite at:
http://172.17.30.248/iw/webdesk/teamsite/launch.jsp
to review and approve/reject or add comments to the document.\n" . $body);
}
sub split_addresses{
my($aref) =
@_
;
my(
@ret)
= ();
foreach my $addr (
@$aref){
my(
@e)
= split(/\s*,\s*/, $addr);
push(
@ret
,
@e)
;
}
return(\
@ret)
;
}
#=====================================================================
# Strip Windows domain name off of any argument before trying to look
# it up or slap a $maildomain on it. Returns stripped arg.
#=====================================================================
sub remove_domain{
my($v) =
@_
;
if ($^O eq "MSWin32"){
$v =~ s|^.*[\\/]||;
}
return($v);
}
#=====================================================================
# Based on 70 character column line lengths - take a string and a
# pattern, and center the string within the pattern.
#=====================================================================
sub center{
my($text, $pat) =
@_
;
return($text) if (length($text) > 66);
return($pat x 70 . "\n") if ($text eq "");
my($len) = (70 - (length($text) + 2)) / 2;
return($pat x $len, " $text ", $pat x $len, "\n");
}
#=====================================================================
# simple debugging routine
#=====================================================================
sub debug {
if ($debug_output) {
print STDERR
@_
;
# Just return if it fails to open debug file
open(OUT, ">>$debug_output") || return;
print OUT
@_
, "\n";
close(OUT);
}
}
////Second file which was part of a search engine I created.
print<<"END";
Content-type: text/html
<html>
<body bgcolor='white'>
<H2><center>Search Results</center></H2>
END
%form = init_cgi();
for my $key (sort keys %form)
{
$count=$count+1;
if ($count==1){
$path = $form{$key};
}
if ($count==2){
$search = $form{$key};
}
$count=1;
}
$count="1";
#############
sub init_cgi
{
my $query = $ENV{QUERY_STRING};
my $length = $ENV{CONTENT_LENGTH};
my (
@assign
, %formlist);
if ($query =~ /\w+/)
{
@assign
= split('&',$query);
}
elsif (defined($length) and $length >0)
{
sysread(STDIN, $_,$length);
chomp;
@assign
= split ('&');
}
foreach (
@assign)
{
my ($name,$value) = split /=/;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
if (defined($formlist{$name}))
{
$formlist{$name} .= ",$value";
}
else
{
$formlist{$name} .= "$value";
}
}
return %formlist;
}
################
#Variable declaration section
$filesfound=0;
$filesmodified=0;
opendir(DIR,$path) or &dirnotfound($dir); #Open directory
$replace='xxxx';
$casesensitive='n';
$prompt='y';
$confirm='y';
$starttime=time; #Record starting time
@directories
= readdir DIR; #Read directory contents
foreach $file (
@directories)
{
$found=0; #Reset the found match(es) variable
@filecontent=()
; #Clear variable that temporarily stores file contents
if (substr($file,0,1) eq '.')
{next;} #'.'=this directory, '..'=up 1 level
open(INF,"$path\\$file") or next; #Open file for input. If fail to open, it is a directory, so goto next file
@filecontent=<
;INF>; #Read entire file contents into variable
close(INF); #Close file
if ($casesensitive eq 'y') { #Perform case sensitive search
foreach $line (
@filecontent)
{
if ($line =~ s/$search/$replace/g) { $found = 1; }
}
} elsif ($casesensitive eq 'n') { #Perform case insensitive search
foreach $line (
@filecontent)
{
if ($line =~ s/$search/$replace/gi) { $found = 1; }
}
}
if ($found) {
$file5 = $path;
$file5 =~ s|Y
|g;
$file5 =~ s|\\|/|g;
$file6 = $file5;
$file6 =~ s|.*/templatedata/||g;
$file8 = $path . "/";
$file8 =~ s|\\|/|g;
$file8 =~ s|Y
|g;
$file7 = $file5;
$file7 =~ s|/templatedata/.*||g;
$stuff = $file8.$file;
#if ($file =~ m/([\d,.]+)/)
#{
# print <<END;
#$file<br>
# <html>
# <body bgcolor="white" text="black">
#<li>
#$file
#END
#}
#else
#{
print <<END;
<!--$file<br>-->
<html>
<body bgcolor="white" text="black">
<li>
<a href="
http://nt16/iw/webdesk/templating/DatacaptureServlet?iw_action=editdcr&iw_area=$file7&iw_dcrVPath=$file8$file&iw-readOnly=y&iw_tdt=$file6
"><IMG src="/iw-icons/fiicon_m.gif" WIDTH="16" HEIGHT="16" BORDER="0" ALIGN="top">$file</a>
END
#}
}
if (!$found) { next; } #Next loop if search string not found
++$filesfound; #Increase the files found counter
}
print<<"END";
<html>
<body bgcolor="white" text="black">
<br>
Click on a filename to view a DCR's.
<br><center><br>
</form>
END
closedir DIR; #Close directory
sub dirnotfound {print "Error: $_[0] directory not found."; exit;}
MattP
This is what I ended up with. Suppose I need to set the EAs now...
$dir = "C:\\iw-home\\httpd\\iw-bin\\testing\\data";
opendir(DIR, $dir) || die "can't open dir: $dir - $!";
@dcrlist
= grep !/^\.{1,2}$/, readdir (DIR);
closedir(DIR);
foreach $x (
@dcrlist)
{
open(DCR, "<$dir/$x");
{
open (OUT, ">$x");
foreach $line (<DCR>)
{
if($line =~ s|</record>|<local><us>#<//us></local></record>|)
{
print OUT $line;
}
else
{
print OUT $line;
}
}
close (OUT);
close (DCR);
}
}
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA
jbonifaci
Matt,
Just out of curiosity, do you not have any sub directories within the data directory? If not, your script is fine. But, like most people, I'm guessing you do. Try something like this:
use TeamSite::Config;
my $iwhome = TeamSite::Config::iwgethome();
my $dir = "C:\\iw-home\\httpd\\iw-bin\\testing\\data";
my $outDir = "";
&processDir($dir, $outDir);
sub processDir
{
my ($file, $outDir) =
@_
;
if (-f $file)
{
&convertDcr($file, $outDir);
}
else # directory
{
unless (-e "$outDir") {`mkdir "$outDir"`}
opendir(SOURCE, $file);
my
@files
= grep !/^\.{1,2}$/, readdir(SOURCE);
closedir(SOURCE);
foreach my $nodeFile (
@files)
{&processDir("$file\\$nodeFile", "$outDir\\$nodeFile\\")};
}
}
sub convertDcr
{
my ($oldDcr, $newDcr) =
@_
;
open(OLDDCR, "<$oldDcr");
my $dcrContent = join('', <OLDDCR>);
close(OLDDCR);
$dcrContent =~ s|</record>|<local><us>#</us></local></record>|g;
open(NEWDCR, ">$newDcr");
print NEWDCR $dcrContent;
close(NEWDCR);
my
@oldDcrEAs
= `$iwhome/bin/iwextattr -l $oldDcr`;
foreach my $ea (
@oldDcrEAs)
{
my ($key, $value) = split('=', $ea);
`$iwhome/bin/iwextattr -s $ea $newDcr`;
}
}
Now, if all you are doing is changing your DCT and you just want to modify all of your dcrs, you don't need to create new dcrs or modify EAs, all you need to do is modify the existing dcrs. In which case, the following code should work for you:
my $dir = "C:\\iw-home\\httpd\\iw-bin\\testing\\data";
&processDir($dir);
sub processDir
{
my ($file) =
@_
;
if (-f $file)
{
&convertDcr($file);
}
else # directory
{
opendir(SOURCE, $file);
my
@files
= grep !/^\.{1,2}$/, readdir(SOURCE);
closedir(SOURCE);
foreach my $nodeFile (
@files)
{&processDir("$file\\$nodeFile")};
}
}
sub convertDcr
{
my ($dcr) =
@_
;
open(DCR, "<$dcr");
my $dcrContent = join('', <DCR>);
close(DCR);
$dcrContent =~ s|</record>|<local><us>#</us></local></record>|g;
open(DCR, ">$dcr");
print DCR $dcrContent;
close(DCR);
}
To answer your question though, to set the same EAs that are on one dcr, on another, this bit of code from my first code bunch is what does it:
my
@oldDcrEAs
= `$iwhome/bin/iwextattr -l $oldDcr`;
foreach my $ea (
@oldDcrEAs)
{
my ($key, $value) = split('=', $ea);
`$iwhome/bin/iwextattr -s $ea $newDcr`;
}
And just any fyi, all of the above code is untested, but should work.
Hope this helps,
Jeff Bonifaci
MattP
Good stuff. At some point I am sure I will use a lot of this code. My data directory is flat, so no worries about looking for directories. I like the way you are setting the EA. All of the files that I need to update are of the same template/dcr type, so it should be a breeze.
Thanks again for your code samples.
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA