Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
iwprv and Perl
Bhargav Coca
Working on Teamsite 6.5, WIN2k. Can any one help we with this code. ( Attached ) . I am trying to read all html files from a directory and sub-directories. While i am reading all the files, i am checking if the file is private using "iwprv" , well my problem is that, its checking html files in my parent directory, and not checking for any files in my sub-folders. Because, it cannot find a file in the sub-directory. Can any one suggest me a way to do this please.
Thanks
Find more posts tagged with
Comments
akshathp
A quick note, in this for loop:
foreach $filedir(
@sourcedir){
...
my $commandext=qq^$iwexternal -g "Opening Date" $path"/$srcfile"^;
my $commandprv=qq^$iwprivate -g $path"/$srcfile"^;
...
}
you are using
$srcfile
instead of
$filedir
.
Do you want to correct that and try again?
Akshat Pramod Sharma
Adam Stoller
Besides what akshat already pointed out - perhaps you can explain what you
think
the following two subroutines are doing - and why:
sub sourcefind {
open(FL, $File::Find::name);
# print $File::Find::name;
push
@sourcefiles
, $_ if -f and /\.htm*/ ;
close(FL);
}
sub wanted{
open(FIL, $File::Find::name);
# print $File::Find::name;
push
@sourcedir
, $_ if -d ;
close(FIL);
}
Actually, looking even more at the code that akshat identified as having a problem - the entire loop looks questionable. It's pretty clear that your
$filedir
loop is essentially an exact copy of your
$srcfile
loop - to the point at which it makes no sense. So please explain what you
wanted
to do in this loop:
foreach $filedir(
@sourcedir){
#print $filedir."\n";
my $iwexternal="$iwhome/bin/iwextattr.exe";
my $iwprivate="$iwhome/bin/iwprv.exe";
my $commandext=qq^$iwexternal -g "Opening Date" $path"/$srcfile"^;
my $commandprv=qq^$iwprivate -g $path"/$srcfile"^;
my $output = `$commandext`;
my $output2 = `$commandprv`;
if ($output2 == 0){
print "$path/$filedir";
}else{
print " this is a private file";
}
}
Do you really want to be reading the contents of the HTML files - or are you just trying to identify which HTML files are marked as private and have (or don't have?) some particular metadata value?
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Bhargav Coca
yes the code is pretty messy at this stage, i was trying two things at the same time. I am trying just read out all the html files which are not private. its as simple as it is. Since i am hardcoding the path to the parent directory which is "sample" in my case, any sub-dir/folder having some html files are not getting checked for 'private'. Because my foreach loop couldn't detect the enire path for the sub-folder html files. can you please tell me how can i make my code to check the 'private' of all the files in the sub-folders too, and return me the metadata of "opening date" to me.
Thanks
Adam Stoller
Please clarify some points:
Do you want a list of:
- all private HTML files that contain an "opening date" metadata value?
- all private HTML files that do not contain an "opening date" metadata value?
- all non-private HTML files that contain an "opening date" metadata value?
- all non-private HTML files that do not contain an "opening date" metadata value?
or something else?
Do you want to recurse down private directories? (if you're looking for non-private files it doesn't make sense to do so. If you're looking for private files it may make sense to do so).
What should the listing contain?
- the file-system path of the file or the vpath of the file?
- the status (public/private)?
- the "opening date" metadata value?
Do you care about the directories processed - or just the files that meet your criteria (which the answers to the above questions will help clarify)?
The code for doing this is not that difficult - and I might even throw it together - but if you don't provide a clearer description of what you are trying to accomplish you're going to be stuck trying to modify what I give you to do what you want (which doesn't really bother me, but ...)
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Bhargav Coca
I want a List of
-all non-private HTML files that contain an "opening date" metadata value?
Thats my final goal. To get a listing of all files which are not private.
Yes i want to recurse down private directories too, and grab any public html files with metadata of "Opening date in it".
My listing should contain list of all the files which are non-private and corresponding opening date of these files.
I care about my directories processed, it has to process all the files under my parent directory for example in my snippet "sample" and all the directories which are under this sample directory. for example in my snippet it is "2001", "2002" son on and so forth.
Can you tell me one thing here, i can do the rest of the stuff, can you please tell me how can get the fullpath for my file in my foreach loop. if i get that, i can use it to appent it with the file name and then i guess i can check for the file, at that point the program will not throw any errors because it detects the files i the subdirectories too.
Thank you
Adam Stoller
I'm still not sure I completely understand - especially why you'd want to traverse down private directories if you're looking for non-private files - but I believe the following will get you a lot closer to where you want to be:
use strict;
use TeamSite::Config;
my $iwmount = TeamSite::Config::iwgetmount();
my $iwhome = TeamSite::Config::iwgethome();
my $path = "$iwmount/default/main/playground/bhargavc/WORKAREA/workarea/sample";
my
@directory
= ($path);
my %pfiles;
process_dir($_) foreach(
@directory)
;
print "$_ => $pfiles{$_}\n" foreach(sort(keys(%pfiles)));
sub process_dir{
my $dir = shift;
(my $vdir = $dir) =~ s|^$iwmount||;
my
@subdirs
;
## To avoid recursing through private directories
## uncomment the next two lines lines
#chomp(my $prv = qx($iwhome/bin/iwprv -g "$vdir"));
#return if ($prv);
if (opendir(DIR, $dir)){
my
@entries
= readdir(DIR);
closedir(DIR);
foreach(
@entries){
next if /^\.+$/;
push(
@subdirs
, "$dir/$_") && next if (-d "$dir/$_");
next if !/\.html?$/;
chomp(my $opdate = qx($iwhome/bin/iwextattr -g "Opening Date" "$vdir/$_"));
chomp(my $prv = qx($iwhome/bin/iwprv -g "$vdir/$_"));
$opdate ||= "[value-not-set]";
$pfiles{"$dir/$_"} = $opdate if (!$prv);
}
}
process_dir($_) foreach(
@subdirs)
;
}
Enjoy.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Bhargav Coca
Awesome Ghoti, Thank you every much, it works like a magic.
Thank you Once again
Bhargav Coca
I have a simple question here, I was trying to print the output of you program, by including the code in the tpl and output it to generate page in this case plain html. Well i am using iwpr_output(scalar). To print the Opening Date i said ' iwpt_output(qq($pfiles{"$dir/$_"})); ', in the foreach(
@entries)
, btu this seems to be not working, if i just run the same line with print statement on the box it works fine, do you know the reason for this? Please let me know.
Thanks
Adam Stoller
Off hand - no - I don't know why it's not working for you - you could try leaving out the qq() part and see if that helps.
You could try using the '-ocode' flag with iwpt_compile and then see if you can track down the problem by running the resulting perl code with the perl debugger.
If not - please post the PT code - with sufficient context above and below the line in question for us to look at.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Bhargav Coca
its still the same thing fish. I am not able to make that possible from a tpl, i have tried removing the qq, that doesn't help.
Here is the snippet where it is.
<iw_perl><![CDATA[
my
@directory
= ($path);
my
@sourcefiles
;
my $srcfile;
my %pfiles;
process_dir($_) foreach(
@directory)
;
#iwpt_output("$_ => $pfiles{$_}\n") foreach(sort(keys(%pfiles)));
sub process_dir{
my $dir = shift;
(my $vdir = $dir) =~ s|^$IWMount||;
my
@subdirs
;
if (opendir(DIR, $dir)){
my
@entries
= readdir(DIR);
closedir(DIR);
foreach(
@entries){
next if /^\.+$/;
push(
@subdirs
, "$dir/$_") && next if (-d "$dir/$_");
next if !/\.html?$/;
chomp(my $opdate = qx($iwhome/bin/iwextattr -g "Opening Date" "$vdir/$_"));
chomp(my $prv = qx($iwhome/bin/iwprv -g "$vdir/$_"));
$pfiles{"$dir/$_"} = $opdate if (!$prv);
iwpt_output(qq($pfiles{"$dir/$_"})); iwpt_output(qq(<br><a href="$vdir/$_">$_</a></br>));
}
}
process_dir($_)
foreach(
@subdirs)
;
}
]]></iw_perl>
Please help me here, i don't have access to the box, so can't runt he -ocode. Please let me know what can i do to make it work?
Thanks
jbonifaci
lilly, if you upload the attached cgi to your iw-bin, you will be able to debug the presentation template using the command line tools. Just make sure the iwperl path is correct in the shebang line. Then just access it as you would any other cgi (<server>/iw-bin/cgiCommandLine.cgi). Then use it as you would a windows command prompt. Interactive commands will barf with it, but for most of your command line needs it will come in handy. It will help make your life easier if you don't have telnet access.
Adam Stoller
First off - I would remove the iwpt_output() line you inserted in process_dir() and replace the commented-out line you have with something like:
foreach(sort(keys(%pfiles))){
(my $url = $_) =~ s|^/WORKAREA/[^/]+|
yourserver>http://
yourserver
|;
# guessing at what you want here
iwpt_output("<a href='$url' target='_blank'>$_</a><br/>\n");
}
If that doesn't work - I'm not sure what to tell you - considering I did most of this gratis - you're going to have to figure some of it out on your own...
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Bhargav Coca
I am sorry fish, but all i wanted here is to display the "Opening Date" in my generated page. As key value pair "$pfiles{"$dir/$_"}" gives the Opening date for that particular file in the loop. I was just trying the iwpt_output to display it, which obviously doesn't work. Well my url to the file is working fine. Just need to figure out a way to display some thing like this
06/19/2004
Pressrel2004.html
02/22/2004
Pressrel2004ver1.html
I know, i am doing wrong some where just need to figure out where, can you give me a little push here pleasee.
Thanks
Edited by lilleywhite on 03/08/05 09:33 AM (server time).
Adam Stoller
I've given you about all the pushes I can - you can try the thing that Jon posted - you can try getting access to the server so you can debug it - or you can just add a bunch of debugging lines to do alerts or prints or whatever you want -
YOU are working in the environment.
YOU are having the problem.
YOU are getting paid for this project
YOU need to figure it out.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Bhargav Coca
Ok sir, i am will figure it out and keep you posted.
thanks For all the help
jbonifaci
"
you can try the thing that
Jon
posted
"
I'm assuming you meant me? It's Jeff,
.
Adam Stoller
Oops sorry - I saw "jbon" and somehow thought the 'b' was silent ;-)
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Abuu
Hi Jessica,
I came across a thread in the DevNet site and the description of the problem (error message) matches exactly with the error I am facing today.
(I tried sending this to your email-id but the mail bounced back with an error)
***************************************************************************
Hi,
I am working on Teamsite 6.1 on Win 2003, With OD 6.0 and DD 6.0. My " database.xml " used to have 'dbschema' in it along with database information, now my " database.xml " contains only my database info. When i deploy using workflow, my workflow calls " deploymetadata.ipl " which calls tsg_dd.xml and this file references to database.xml.
Now what i wanted to do is pull out the schemas out of the database.xml and save each and every schema as a *.cfg/*.xml file and create and still should be able to deploy using my workflow.
I am attaching my modified " database.xml" and my tsg_dd.xml and my schema.xml
I have tried it from the command line too but its still giving me a datadeploy error, please help me
Thank You
Jessica
***************************************************************************
In our case, we get to see the following error in the log file and data is not updated in the DataBase. We have recently upgraded to TS 6.5 and OD/DD 6.0.2.
[F:\Apps\iw-home\opendeployng\OpenDeploy\log\src.producttype_dd.ProductType.AWCTMD01.to.database.log] ---------
ENG: 2005-04-20 14:22:21 CDT GMT-05:00 Job ID=m6 Deployment=producttype_dd
ENG: 2005-04-20 14:22:21 CDT GMT-05:00 DataDeploy Version is 6.0.2.0.0
ENG: 2005-04-20 14:22:21 CDT GMT-05:00 Owner started the deployment is AZLIFEM\azl6kel
ENG: 2005-04-20 14:22:21 CDT GMT-05:00 DD args iwdd="ProductType" cfg=F:\Apps\iw-home\opendeployng\OpenDeploy\conf\producttype_dd.xml need-result=yes depuuid=84ceb200-b1d1-11d9-b2c8-b6155df18219 leglabel=database
ENG: 2005-04-20 14:22:21 CDT GMT-05:00 Proceed to execute the database deployment
DAS: Deployment : ProductType
DAS: ERROR
eployment not found
DAS: ERROR:ERROR: Unable to determine operation mode
DAS:
### IWDataDeploy FAILED ###
DAS:
### Sending result ###
ENG: 2005-04-20 14:22:21 CDT GMT-05:00 Database deployment execution returned 1
ENG: 2005-04-20 14:22:21 CDT GMT-05:00 <<< Completed database deployment Invocation>>>
ENG: 2005-04-20 14:22:21 CDT GMT-05:00 Job ID=m6 Deployment leg=database Elapsed Time=47 ms <<<
ENG: 2005-04-20 14:22:21 CDT GMT-05:00 End logfile [F:\Apps\iw-home\opendeployng\OpenDeploy\log\src.producttype_dd.ProductType.AWCTMD01.to.database.log]
How did you get the issue resolved. Any help would be appreciated.
Thanks
Faisal