RE: Win32 OLE modification of component identity
> Try something like this. > > $COMComponent->{Value}->{Identity} = $varUserStr; > $COMComponent->{Value}->{Password} = $varPasswordStr; > > There seems to be no Identity property on the Com Component Object, > instead, the user and pw are part of a variant of the Value property. Nope, this looks like an indexed property. The correct syntax to assign to them would be $COMComponent->LetProperty("Value", "Identity", $varUserStr); "Value" is the property name, "Identity" is the first (and only) argument to the property, and $varUserStr is the new value. Some general hints about using Win32::OLE: * Always use "use strict". Without it Win32::OLE invokes some additional heuristics for backwards compatibility that you most likely don't want. They just tend to confuse things when you already made a mistake. * Run with "perl -w" and Win32::OLE will produce warnings whenever an OLE function call fails. That way you don't have to print Win32::OLE->LastError() all over the place during debugging. Cheers, -Jan ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::Exchange module
Ok, I used the example script and trimmed it down so that I'm only using what I need and this is the output version = 6.0 build= 6249.4 service pack = 3 Failed creating CDO.Person object - Error returning into main from new () Here is the script below... #!/usr/local/bin/perl use Win32::Exchange; $domain = Win32::DomainName(); $info_store_server="delta"; $mta_server=$info_store_server; # this could be different, but for testing, we'll set them the same $storage_group = ""; # you'd need to define this if you had more than 1 storage group on 1 server. $mailbox_store = ""; # you'd need to define this if you had more than 1 mailbox store on 1 or more storage groups. $mailbox_alias_name='hjablome'; $givenName = "Heywood"; $sn = "Jablome"; $mailbox_full_name="$givenName $mailbox_alias_name $sn"; #$distribution_list="Users"; # group / DL the user will be added to. $email_domain = "foo.com"; #$trustee_group = "Domain Admins"; # the group that has permission to log into this mailbox as well as the recipient if (!Win32::Exchange::GetVersion($info_store_server,\%ver) ) { print "$rtn - Error returning into main from GetVersion\n"; exit 0; } print "version = $ver{ver}\n"; print "build= $ver{build}\n"; print "service pack = $ver{sp}\n"; if (!($provider = Win32::Exchange::Mailbox->new($info_store_server))) { print "$rtn - Error returning into main from new ($Win32::Exchange::VERSION)\n"; exit 0; } e60(); sub e60 { if (Win32::Exchange::LocateMailboxStore($info_store_server,$storage_group,$mailbox_store,$store_name,[EMAIL PROTECTED])) { print "storage group = $storage_group\n"; print "mailbox store = $mailbox_store\n"; print "located store distinguished name= $store_name\n"; print "$info_store_server\n"; print " Total:\n"; print "storage groups = $counts[0]\n"; print "mailbox stores = $counts[1]\n"; } if ($mailbox = $provider->GetMailbox($mailbox_alias_name)) { print "Got Mailbox successfully\n"; } else { print "Mailbox did not exist\n"; if ($mailbox = $provider->CreateMailbox($mailbox_alias_name ) ) { print "Mailbox create succeeded.\n"; } else { print "Mailbox creation failed.\n"; exit 0; } } } Thanks for the help, Chris P. > The embedded HTML example might be a little off -- not sure when I last > updated it. But now see that I should be updating it a little more > often. > > Instead, please use the exchange_example.pl located in the > perl\site\lib\win32 directory. > > Sorry for any confusion. > > Steven > ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32 OLE modification of component identity
As always, THANK YOU (for correcting my mistakes)! I knew it was just a syntactical error. I, just, didn't know the right syntax to throw it. :) Steven -Original Message- From: Jan Dubois [mailto:[EMAIL PROTECTED] Sent: Monday, May 03, 2004 1:51 PM To: Steven Manross; 'Miguel Laborde'; [EMAIL PROTECTED] Subject: RE: Win32 OLE modification of component identity > Try something like this. > > $COMComponent->{Value}->{Identity} = $varUserStr; > $COMComponent->{Value}->{Password} = $varPasswordStr; > > There seems to be no Identity property on the Com Component Object, > instead, the user and pw are part of a variant of the Value property. Nope, this looks like an indexed property. The correct syntax to assign to them would be $COMComponent->LetProperty("Value", "Identity", $varUserStr); "Value" is the property name, "Identity" is the first (and only) argument to the property, and $varUserStr is the new value. Some general hints about using Win32::OLE: * Always use "use strict". Without it Win32::OLE invokes some additional heuristics for backwards compatibility that you most likely don't want. They just tend to confuse things when you already made a mistake. * Run with "perl -w" and Win32::OLE will produce warnings whenever an OLE function call fails. That way you don't have to print Win32::OLE->LastError() all over the place during debugging. Cheers, -Jan ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::Exchange module
Load the Exchange Admin tools on the system that the script is running on. Steven -Original Message- From: Chris Purcell [mailto:[EMAIL PROTECTED] Sent: Monday, May 03, 2004 1:57 PM To: Steven Manross Cc: [EMAIL PROTECTED] Subject: RE: Win32::Exchange module Ok, I used the example script and trimmed it down so that I'm only using what I need and this is the output version = 6.0 build= 6249.4 service pack = 3 Failed creating CDO.Person object - Error returning into main from new () Here is the script below... #!/usr/local/bin/perl use Win32::Exchange; $domain = Win32::DomainName(); $info_store_server="delta"; $mta_server=$info_store_server; # this could be different, but for testing, we'll set them the same $storage_group = ""; # you'd need to define this if you had more than 1 storage group on 1 server. $mailbox_store = ""; # you'd need to define this if you had more than 1 mailbox store on 1 or more storage groups. $mailbox_alias_name='hjablome'; $givenName = "Heywood"; $sn = "Jablome"; $mailbox_full_name="$givenName $mailbox_alias_name $sn"; #$distribution_list="Users"; # group / DL the user will be added to. $email_domain = "foo.com"; #$trustee_group = "Domain Admins"; # the group that has permission to log into this mailbox as well as the recipient if (!Win32::Exchange::GetVersion($info_store_server,\%ver) ) { print "$rtn - Error returning into main from GetVersion\n"; exit 0; } print "version = $ver{ver}\n"; print "build= $ver{build}\n"; print "service pack = $ver{sp}\n"; if (!($provider = Win32::Exchange::Mailbox->new($info_store_server))) { print "$rtn - Error returning into main from new ($Win32::Exchange::VERSION)\n"; exit 0; } e60(); sub e60 { if (Win32::Exchange::LocateMailboxStore($info_store_server,$storage_group,$ mailbox_store,$store_name,[EMAIL PROTECTED])) { print "storage group = $storage_group\n"; print "mailbox store = $mailbox_store\n"; print "located store distinguished name= $store_name\n"; print "$info_store_server\n"; print " Total:\n"; print "storage groups = $counts[0]\n"; print "mailbox stores = $counts[1]\n"; } if ($mailbox = $provider->GetMailbox($mailbox_alias_name)) { print "Got Mailbox successfully\n"; } else { print "Mailbox did not exist\n"; if ($mailbox = $provider->CreateMailbox($mailbox_alias_name ) ) { print "Mailbox create succeeded.\n"; } else { print "Mailbox creation failed.\n"; exit 0; } } } Thanks for the help, Chris P. > The embedded HTML example might be a little off -- not sure when I > last updated it. But now see that I should be updating it a little > more often. > > Instead, please use the exchange_example.pl located in the > perl\site\lib\win32 directory. > > Sorry for any confusion. > > Steven > ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::Exchange module
They are installed and patched to SP3. Chris > Load the Exchange Admin tools on the system that the script is running > on. > > Steven ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::Exchange module
Something is wrong with the CDO.Person COM object. Try this... use Win32::OLE; my $this_object = Win32::OLE->new("CDO.Person"); if (Win32::OLE->LastError() != 0 ) { print "Error: ".Win32::OLE->LastError()."\n"; } else { print "Well, that worked.. What's up with that?\n"; } If it doesn't work, you might need to uninstall/reinstall the tools. The module needs the CDO.Person COM object for Exchange 2000/2003 mailbox manipulation. Steven -Original Message- From: Chris Purcell [mailto:[EMAIL PROTECTED] Sent: Monday, May 03, 2004 2:08 PM To: Steven Manross Cc: [EMAIL PROTECTED] Subject: RE: Win32::Exchange module They are installed and patched to SP3. Chris > Load the Exchange Admin tools on the system that the script is running > on. > > Steven ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::Exchange module
You might get away with registering the DLL (because maybe the install messed it up somehow)? C:\ Cd\Program Files\Common Files\Microsoft Shared\CDO Regsvr32 cdoex.dll Steven -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steven Manross Sent: Monday, May 03, 2004 2:33 PM To: Chris Purcell Cc: [EMAIL PROTECTED] Subject: RE: Win32::Exchange module Something is wrong with the CDO.Person COM object. Try this... use Win32::OLE; my $this_object = Win32::OLE->new("CDO.Person"); if (Win32::OLE->LastError() != 0 ) { print "Error: ".Win32::OLE->LastError()."\n"; } else { print "Well, that worked.. What's up with that?\n"; } If it doesn't work, you might need to uninstall/reinstall the tools. The module needs the CDO.Person COM object for Exchange 2000/2003 mailbox manipulation. Steven -Original Message- From: Chris Purcell [mailto:[EMAIL PROTECTED] Sent: Monday, May 03, 2004 2:08 PM To: Steven Manross Cc: [EMAIL PROTECTED] Subject: RE: Win32::Exchange module They are installed and patched to SP3. Chris > Load the Exchange Admin tools on the system that the script is running > on. > > Steven ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32::Exchange module
The embedded HTML example might be a little off -- not sure when I last updated it. But now see that I should be updating it a little more often. Instead, please use the exchange_example.pl located in the perl\site\lib\win32 directory. Sorry for any confusion. Steven -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chris Purcell Sent: Monday, May 03, 2004 12:57 PM To: [EMAIL PROTECTED] Subject: Win32::Exchange module I'm using the Win32::Exchange module to create mailboxes on an Exchange 2000 server. I'm getting this error... "Can't call method "GetMailbox" on unblessed reference at C:\addusers.pl line 98." As of right now, I just copied and pasted some of the examples from the documentation here... http://search.cpan.org/src/SMANROSS/Win32-Exchange_v0.042/html/site/lib/ Win32/Exchange/Mailbox.html#examples I'm really not that familiar with OOP and have no idea what it means to "bless" a reference. Here is my code that I copied and pasted from the examples in the documentation. $domain = Win32::DomainName(); $info_store_server="delta"; $mta_server=$info_store_server; $storage_group = ""; $mailbox_store = ""; $mailbox_alias_name='hjablome'; # username $givenName = "Heywood"; # firstname $sn = "Jablome"; # lastname $mailbox_full_name="$givenName $mailbox_alias_name $sn"; $email_domain = "foo.com"; if (!Win32::Exchange::GetVersion($info_store_server,\%ver) ) { print "$rtn - Error returning into main from GetVersion\n"; exit 0; } print "version = $ver{ver}\n"; print "build= $ver{build}\n"; print "service pack = $ver{sp}\n"; $dc = $provider->{dc}; if (Win32::Exchange::LocateMailboxStore($info_store_server,$storage_group,$ mailbox_store,$store_name,[EMAIL PROTECTED])) { print "storage group = $storage_group\n"; print "mailbox store = $mailbox_store\n"; print "located store distinguished name= $store_name\n"; print "$info_store_server\n"; print " Total:\n"; print "storage groups = $counts[0]\n"; print "mailbox stores = $counts[1]\n"; } if ($mailbox = $provider->GetMailbox($mailbox_alias_name)) { print "Got Mailbox successfully\n"; } else { print "Mailbox did not exist\n"; if ($mailbox = $provider->CreateMailbox($mailbox_alias_name, $email_domain ) ) { print "Mailbox create succeeded.\n"; } else { print "Mailbox creation failed.\n"; exit 0; } } Thanks for the help, Chris ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32 OLE modification of component identity
Generally a "Member Not Found" means that you are trying to put a property that doesn't exist. I.E. Identity and Password As well, from looking at the OLE Browser, it doesn't seem that Identity or Password are accepted properties, only Value. There are situations in which OLE and perl don't work, but I'm guessing this isn't one of them. There's just a syntactical error somewhere. But I am sure about the LetProperty and using Identity as a property name.. That won't work. Maybe somehow setting an Assoc Array for the Value using Put or LetProperty, but I'm not sure how it would want to be set. You've reached the end of my rope. I don't know where to go from here. Sorry. Steven -Original Message- From: Miguel Laborde [mailto:[EMAIL PROTECTED] Sent: Monday, May 03, 2004 12:52 PM To: Steven Manross; [EMAIL PROTECTED] Subject: RE: Win32 OLE modification of component identity Hi Steven, unfortunately this doesn't seem to work. When I try this way I get: Found component Win32::OLE=HASH(0x1f90eb8) 1: Win32::OLE(0.1403) error 0x8002000e: "Invalid number of parameters" in PROPERTYPUT "Value" when the preceeding line is $COMComponent->{Value}->{Identity} = Variant(VT_BSTR, "Interactive User"); Using $COMComponent->LetProperty("Identity", 'Interactive User'); gives no error but the component identity doesn't change. So I'm guessing this must be the right way of doing it but there must be something else I'm missing. It would issue an error if this wasn't a valid call wouldn't it? As you previously mentioned I tried adding the $COMComponent->SetInfo() call afterwards but this gives: Found component Win32::OLE=HASH(0x1f90eac) retrying default method at C:/Perl/site/lib/Win32/OLE/Lite. 1: Win32::OLE(0.1403) error 0x80020003: "Member not found" in METHOD/PROPERTYGET "" I guess this is one of the situations when Win32::OLE isn't fully compatiable with OLE? Thanks -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Steven Manross Sent: Monday, May 03, 2004 3:34 PM To: Miguel Laborde; [EMAIL PROTECTED] Subject: RE: Win32 OLE modification of component identity Lastly, Try something like this. $COMComponent->{Value}->{Identity} = $varUserStr; $COMComponent->{Value}->{Password} = $varPasswordStr; There seems to be no Identity property on the Com Component Object, instead, the user and pw are part of a variant of the Value property. And do a: use Win32::OLE::Variant; At the top for good measure. Not 100% sure this will work, but seems like the way to go after looking at the object model. Steven -Original Message- From: Miguel Laborde [mailto:[EMAIL PROTECTED] Sent: Monday, May 03, 2004 11:29 AM To: Steven Manross; [EMAIL PROTECTED] Subject: RE: Win32 OLE modification of component identity No go unfortunately.. I get the following error: Found component Win32::OLE=HASH(0x1f91e70) Check1 retrying default method at C:/Perl/site/lib/Win32/OLE/Lite.pm line 156. Check2 after modifying the code with: print "Check1\n"; $COMComponent->SetInfo(); print "Check2\n"; >From the VB Code the call to SaveChanges() seems to be the way to >update the component info. Thanks though :) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Steven Manross Sent: Monday, May 03, 2004 2:14 PM To: Miguel Laborde; [EMAIL PROTECTED] Subject: RE: Win32 OLE modification of component identity After a LetProperty, don't you have to do a SetInfo ? That would make sense about why the application doesn't change anyway -- the change wasn't committed to the $COMComponent object. Steven -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Miguel Laborde Sent: Monday, May 03, 2004 11:04 AM To: [EMAIL PROTECTED] Subject: Win32 OLE modification of component identity Hello all, I'm having some trouble modifying the identity/password for a COM+ component using Win32::OLE to do it. I've tried changing it using VBScript and it works fine, however I want this to be done in perl as its part of a suite of other perl utilities I'm working on. Here is the code I'm using. my $comAppName = 'COMName'; my $varUserStr = 'test'; my $varPasswordStr = 'test'; my $COMCatalog = Win32::OLE->new("COMAdmin.COMAdminCatalog"); my $COMApps = $COMCatalog->GetCollection("Applications"); $COMApps->Populate(); my $COMComponent; for(my $counter = 0; $counter <= %$COMApps->{'count'}; $counter++){ $COMComponent = $COMApps->Item($counter); print "Component: $COMComponent Param Name: $comAppName Com Name: ".$COMComponent->{'Name'}."\n" if(DEBUG); last if($COMComponent->{'Name'} eq $comAppName); } # Check to see if we found the component #
Win32::Exchange module
I'm using the Win32::Exchange module to create mailboxes on an Exchange 2000 server. I'm getting this error... "Can't call method "GetMailbox" on unblessed reference at C:\addusers.pl line 98." As of right now, I just copied and pasted some of the examples from the documentation here... http://search.cpan.org/src/SMANROSS/Win32-Exchange_v0.042/html/site/lib/Win32/Exchange/Mailbox.html#examples I'm really not that familiar with OOP and have no idea what it means to "bless" a reference. Here is my code that I copied and pasted from the examples in the documentation. $domain = Win32::DomainName(); $info_store_server="delta"; $mta_server=$info_store_server; $storage_group = ""; $mailbox_store = ""; $mailbox_alias_name='hjablome'; # username $givenName = "Heywood"; # firstname $sn = "Jablome"; # lastname $mailbox_full_name="$givenName $mailbox_alias_name $sn"; $email_domain = "foo.com"; if (!Win32::Exchange::GetVersion($info_store_server,\%ver) ) { print "$rtn - Error returning into main from GetVersion\n"; exit 0; } print "version = $ver{ver}\n"; print "build= $ver{build}\n"; print "service pack = $ver{sp}\n"; $dc = $provider->{dc}; if (Win32::Exchange::LocateMailboxStore($info_store_server,$storage_group,$mailbox_store,$store_name,[EMAIL PROTECTED])) { print "storage group = $storage_group\n"; print "mailbox store = $mailbox_store\n"; print "located store distinguished name= $store_name\n"; print "$info_store_server\n"; print " Total:\n"; print "storage groups = $counts[0]\n"; print "mailbox stores = $counts[1]\n"; } if ($mailbox = $provider->GetMailbox($mailbox_alias_name)) { print "Got Mailbox successfully\n"; } else { print "Mailbox did not exist\n"; if ($mailbox = $provider->CreateMailbox($mailbox_alias_name, $email_domain ) ) { print "Mailbox create succeeded.\n"; } else { print "Mailbox creation failed.\n"; exit 0; } } Thanks for the help, Chris ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32 OLE modification of component identity
Hi Steven, unfortunately this doesn't seem to work. When I try this way I get: Found component Win32::OLE=HASH(0x1f90eb8) 1: Win32::OLE(0.1403) error 0x8002000e: "Invalid number of parameters" in PROPERTYPUT "Value" when the preceeding line is $COMComponent->{Value}->{Identity} = Variant(VT_BSTR, "Interactive User"); Using $COMComponent->LetProperty("Identity", 'Interactive User'); gives no error but the component identity doesn't change. So I'm guessing this must be the right way of doing it but there must be something else I'm missing. It would issue an error if this wasn't a valid call wouldn't it? As you previously mentioned I tried adding the $COMComponent->SetInfo() call afterwards but this gives: Found component Win32::OLE=HASH(0x1f90eac) retrying default method at C:/Perl/site/lib/Win32/OLE/Lite. 1: Win32::OLE(0.1403) error 0x80020003: "Member not found" in METHOD/PROPERTYGET "" I guess this is one of the situations when Win32::OLE isn't fully compatiable with OLE? Thanks -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Steven Manross Sent: Monday, May 03, 2004 3:34 PM To: Miguel Laborde; [EMAIL PROTECTED] Subject: RE: Win32 OLE modification of component identity Lastly, Try something like this. $COMComponent->{Value}->{Identity} = $varUserStr; $COMComponent->{Value}->{Password} = $varPasswordStr; There seems to be no Identity property on the Com Component Object, instead, the user and pw are part of a variant of the Value property. And do a: use Win32::OLE::Variant; At the top for good measure. Not 100% sure this will work, but seems like the way to go after looking at the object model. Steven -Original Message- From: Miguel Laborde [mailto:[EMAIL PROTECTED] Sent: Monday, May 03, 2004 11:29 AM To: Steven Manross; [EMAIL PROTECTED] Subject: RE: Win32 OLE modification of component identity No go unfortunately.. I get the following error: Found component Win32::OLE=HASH(0x1f91e70) Check1 retrying default method at C:/Perl/site/lib/Win32/OLE/Lite.pm line 156. Check2 after modifying the code with: print "Check1\n"; $COMComponent->SetInfo(); print "Check2\n"; >From the VB Code the call to SaveChanges() seems to be the way to update the component info. Thanks though :) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Steven Manross Sent: Monday, May 03, 2004 2:14 PM To: Miguel Laborde; [EMAIL PROTECTED] Subject: RE: Win32 OLE modification of component identity After a LetProperty, don't you have to do a SetInfo ? That would make sense about why the application doesn't change anyway -- the change wasn't committed to the $COMComponent object. Steven -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Miguel Laborde Sent: Monday, May 03, 2004 11:04 AM To: [EMAIL PROTECTED] Subject: Win32 OLE modification of component identity Hello all, I'm having some trouble modifying the identity/password for a COM+ component using Win32::OLE to do it. I've tried changing it using VBScript and it works fine, however I want this to be done in perl as its part of a suite of other perl utilities I'm working on. Here is the code I'm using. my $comAppName = 'COMName'; my $varUserStr = 'test'; my $varPasswordStr = 'test'; my $COMCatalog = Win32::OLE->new("COMAdmin.COMAdminCatalog"); my $COMApps = $COMCatalog->GetCollection("Applications"); $COMApps->Populate(); my $COMComponent; for(my $counter = 0; $counter <= %$COMApps->{'count'}; $counter++){ $COMComponent = $COMApps->Item($counter); print "Component: $COMComponent Param Name: $comAppName Com Name: ".$COMComponent->{'Name'}."\n" if(DEBUG); last if($COMComponent->{'Name'} eq $comAppName); } # Check to see if we found the component if($COMComponent->{'Name'} eq $comAppName){ print "\nFound component $COMComponent\n" if(DEBUG); $COMComponent->LetProperty("Identity", $varUserStr); $COMComponent->LetProperty("Password", $varPasswordStr); $COMApps->SaveChanges(); print "Identity: ".$COMComponent->Value("Identity")."\n"; print "Password: ".$COMComponent->Value("Password")."\n"; } I don't get any errors when I run this but the identity/password doesn't change, stays the default of Interactive User. When I run the following vbscript it works: '--- --- ' Install COM+ Components '---
RE: Win32 OLE modification of component identity
Lastly, Try something like this. $COMComponent->{Value}->{Identity} = $varUserStr; $COMComponent->{Value}->{Password} = $varPasswordStr; There seems to be no Identity property on the Com Component Object, instead, the user and pw are part of a variant of the Value property. And do a: use Win32::OLE::Variant; At the top for good measure. Not 100% sure this will work, but seems like the way to go after looking at the object model. Steven -Original Message- From: Miguel Laborde [mailto:[EMAIL PROTECTED] Sent: Monday, May 03, 2004 11:29 AM To: Steven Manross; [EMAIL PROTECTED] Subject: RE: Win32 OLE modification of component identity No go unfortunately.. I get the following error: Found component Win32::OLE=HASH(0x1f91e70) Check1 retrying default method at C:/Perl/site/lib/Win32/OLE/Lite.pm line 156. Check2 after modifying the code with: print "Check1\n"; $COMComponent->SetInfo(); print "Check2\n"; >From the VB Code the call to SaveChanges() seems to be the way to update the component info. Thanks though :) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Steven Manross Sent: Monday, May 03, 2004 2:14 PM To: Miguel Laborde; [EMAIL PROTECTED] Subject: RE: Win32 OLE modification of component identity After a LetProperty, don't you have to do a SetInfo ? That would make sense about why the application doesn't change anyway -- the change wasn't committed to the $COMComponent object. Steven -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Miguel Laborde Sent: Monday, May 03, 2004 11:04 AM To: [EMAIL PROTECTED] Subject: Win32 OLE modification of component identity Hello all, I'm having some trouble modifying the identity/password for a COM+ component using Win32::OLE to do it. I've tried changing it using VBScript and it works fine, however I want this to be done in perl as its part of a suite of other perl utilities I'm working on. Here is the code I'm using. my $comAppName = 'COMName'; my $varUserStr = 'test'; my $varPasswordStr = 'test'; my $COMCatalog = Win32::OLE->new("COMAdmin.COMAdminCatalog"); my $COMApps = $COMCatalog->GetCollection("Applications"); $COMApps->Populate(); my $COMComponent; for(my $counter = 0; $counter <= %$COMApps->{'count'}; $counter++){ $COMComponent = $COMApps->Item($counter); print "Component: $COMComponent Param Name: $comAppName Com Name: ".$COMComponent->{'Name'}."\n" if(DEBUG); last if($COMComponent->{'Name'} eq $comAppName); } # Check to see if we found the component if($COMComponent->{'Name'} eq $comAppName){ print "\nFound component $COMComponent\n" if(DEBUG); $COMComponent->LetProperty("Identity", $varUserStr); $COMComponent->LetProperty("Password", $varPasswordStr); $COMApps->SaveChanges(); print "Identity: ".$COMComponent->Value("Identity")."\n"; print "Password: ".$COMComponent->Value("Password")."\n"; } I don't get any errors when I run this but the identity/password doesn't change, stays the default of Interactive User. When I run the following vbscript it works: '--- --- ' Install COM+ Components '--- --- Dim i Dim Catalog Set Catalog = CreateObject("COMAdmin.COMAdminCatalog") Dim Applications Set Applications = Catalog.GetCollection("Applications") Applications.Populate Dim CoreApp For i = 0 To Applications.Count - 1 Set CoreApp = Applications.Item(i) If CoreApp.Name = "COMName" Then Exit For End If Next '// ' Apply config settings to the COM+ application '// CoreApp.Value("Identity") = "test" CoreApp.Value("Password") = "test" Applications.SaveChanges Thanks for any help! ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32 OLE modification of component identity
Thanks Steven, I did as you suggested. The result is: retrying default method at C:/Perl/site/lib/Win32/OLE/Lite.pm line 156. 1: Win32::OLE(0.1403) error 0x80020003: "Member not found" in METHOD/PROPERTYGET "" Having a look on Microsoft's website gives a link to this http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q172/1/08.asp&NoWebContent=1&NoWebContent=1 Though I don't know if any of that applies to this.. I did see somewhere else about needing to apply a service patch to Visual Studio when this error occurs, though I don't know if this will fix the problem I'm having. Thanks -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Steven Manross Sent: Monday, May 03, 2004 2:46 PM To: Miguel Laborde; [EMAIL PROTECTED] Subject: RE: Win32 OLE modification of component identity You should really start using Win32::OLE->LastError() to see what and where it doesn't like the code. i.e. if (Win32::OLE->LastError() != 0) { print "1: ".Win32::OLE->LastError()."\n"; } Steven -Original Message- From: Miguel Laborde [mailto:[EMAIL PROTECTED] Sent: Monday, May 03, 2004 11:29 AM To: Steven Manross; [EMAIL PROTECTED] Subject: RE: Win32 OLE modification of component identity No go unfortunately.. I get the following error: Found component Win32::OLE=HASH(0x1f91e70) Check1 retrying default method at C:/Perl/site/lib/Win32/OLE/Lite.pm line 156. Check2 after modifying the code with: print "Check1\n"; $COMComponent->SetInfo(); print "Check2\n"; >From the VB Code the call to SaveChanges() seems to be the way to update the component info. Thanks though :) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Steven Manross Sent: Monday, May 03, 2004 2:14 PM To: Miguel Laborde; [EMAIL PROTECTED] Subject: RE: Win32 OLE modification of component identity After a LetProperty, don't you have to do a SetInfo ? That would make sense about why the application doesn't change anyway -- the change wasn't committed to the $COMComponent object. Steven -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Miguel Laborde Sent: Monday, May 03, 2004 11:04 AM To: [EMAIL PROTECTED] Subject: Win32 OLE modification of component identity Hello all, I'm having some trouble modifying the identity/password for a COM+ component using Win32::OLE to do it. I've tried changing it using VBScript and it works fine, however I want this to be done in perl as its part of a suite of other perl utilities I'm working on. Here is the code I'm using. my $comAppName = 'COMName'; my $varUserStr = 'test'; my $varPasswordStr = 'test'; my $COMCatalog = Win32::OLE->new("COMAdmin.COMAdminCatalog"); my $COMApps = $COMCatalog->GetCollection("Applications"); $COMApps->Populate(); my $COMComponent; for(my $counter = 0; $counter <= %$COMApps->{'count'}; $counter++){ $COMComponent = $COMApps->Item($counter); print "Component: $COMComponent Param Name: $comAppName Com Name: ".$COMComponent->{'Name'}."\n" if(DEBUG); last if($COMComponent->{'Name'} eq $comAppName); } # Check to see if we found the component if($COMComponent->{'Name'} eq $comAppName){ print "\nFound component $COMComponent\n" if(DEBUG); $COMComponent->LetProperty("Identity", $varUserStr); $COMComponent->LetProperty("Password", $varPasswordStr); $COMApps->SaveChanges(); print "Identity: ".$COMComponent->Value("Identity")."\n"; print "Password: ".$COMComponent->Value("Password")."\n"; } I don't get any errors when I run this but the identity/password doesn't change, stays the default of Interactive User. When I run the following vbscript it works: '--- --- ' Install COM+ Components '--- --- Dim i Dim Catalog Set Catalog = CreateObject("COMAdmin.COMAdminCatalog") Dim Applications Set Applications = Catalog.GetCollection("Applications") Applications.Populate Dim CoreApp For i = 0 To Applications.Count - 1 Set CoreApp = Applications.Item(i) If CoreApp.Name = "COMName" Then Exit For End If Next '// ' Apply config settings to the COM+ application '// CoreA
RE: Win32 OLE modification of component identity
You should really start using Win32::OLE->LastError() to see what and where it doesn't like the code. i.e. if (Win32::OLE->LastError() != 0) { print "1: ".Win32::OLE->LastError()."\n"; } Steven -Original Message- From: Miguel Laborde [mailto:[EMAIL PROTECTED] Sent: Monday, May 03, 2004 11:29 AM To: Steven Manross; [EMAIL PROTECTED] Subject: RE: Win32 OLE modification of component identity No go unfortunately.. I get the following error: Found component Win32::OLE=HASH(0x1f91e70) Check1 retrying default method at C:/Perl/site/lib/Win32/OLE/Lite.pm line 156. Check2 after modifying the code with: print "Check1\n"; $COMComponent->SetInfo(); print "Check2\n"; >From the VB Code the call to SaveChanges() seems to be the way to update the component info. Thanks though :) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Steven Manross Sent: Monday, May 03, 2004 2:14 PM To: Miguel Laborde; [EMAIL PROTECTED] Subject: RE: Win32 OLE modification of component identity After a LetProperty, don't you have to do a SetInfo ? That would make sense about why the application doesn't change anyway -- the change wasn't committed to the $COMComponent object. Steven -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Miguel Laborde Sent: Monday, May 03, 2004 11:04 AM To: [EMAIL PROTECTED] Subject: Win32 OLE modification of component identity Hello all, I'm having some trouble modifying the identity/password for a COM+ component using Win32::OLE to do it. I've tried changing it using VBScript and it works fine, however I want this to be done in perl as its part of a suite of other perl utilities I'm working on. Here is the code I'm using. my $comAppName = 'COMName'; my $varUserStr = 'test'; my $varPasswordStr = 'test'; my $COMCatalog = Win32::OLE->new("COMAdmin.COMAdminCatalog"); my $COMApps = $COMCatalog->GetCollection("Applications"); $COMApps->Populate(); my $COMComponent; for(my $counter = 0; $counter <= %$COMApps->{'count'}; $counter++){ $COMComponent = $COMApps->Item($counter); print "Component: $COMComponent Param Name: $comAppName Com Name: ".$COMComponent->{'Name'}."\n" if(DEBUG); last if($COMComponent->{'Name'} eq $comAppName); } # Check to see if we found the component if($COMComponent->{'Name'} eq $comAppName){ print "\nFound component $COMComponent\n" if(DEBUG); $COMComponent->LetProperty("Identity", $varUserStr); $COMComponent->LetProperty("Password", $varPasswordStr); $COMApps->SaveChanges(); print "Identity: ".$COMComponent->Value("Identity")."\n"; print "Password: ".$COMComponent->Value("Password")."\n"; } I don't get any errors when I run this but the identity/password doesn't change, stays the default of Interactive User. When I run the following vbscript it works: '--- --- ' Install COM+ Components '--- --- Dim i Dim Catalog Set Catalog = CreateObject("COMAdmin.COMAdminCatalog") Dim Applications Set Applications = Catalog.GetCollection("Applications") Applications.Populate Dim CoreApp For i = 0 To Applications.Count - 1 Set CoreApp = Applications.Item(i) If CoreApp.Name = "COMName" Then Exit For End If Next '// ' Apply config settings to the COM+ application '// CoreApp.Value("Identity") = "test" CoreApp.Value("Password") = "test" Applications.SaveChanges Thanks for any help! ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32 OLE modification of component identity
No go unfortunately.. I get the following error: Found component Win32::OLE=HASH(0x1f91e70) Check1 retrying default method at C:/Perl/site/lib/Win32/OLE/Lite.pm line 156. Check2 after modifying the code with: print "Check1\n"; $COMComponent->SetInfo(); print "Check2\n"; >From the VB Code the call to SaveChanges() seems to be the way to update the >component info. Thanks though :) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Steven Manross Sent: Monday, May 03, 2004 2:14 PM To: Miguel Laborde; [EMAIL PROTECTED] Subject: RE: Win32 OLE modification of component identity After a LetProperty, don't you have to do a SetInfo ? That would make sense about why the application doesn't change anyway -- the change wasn't committed to the $COMComponent object. Steven -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Miguel Laborde Sent: Monday, May 03, 2004 11:04 AM To: [EMAIL PROTECTED] Subject: Win32 OLE modification of component identity Hello all, I'm having some trouble modifying the identity/password for a COM+ component using Win32::OLE to do it. I've tried changing it using VBScript and it works fine, however I want this to be done in perl as its part of a suite of other perl utilities I'm working on. Here is the code I'm using. my $comAppName = 'COMName'; my $varUserStr = 'test'; my $varPasswordStr = 'test'; my $COMCatalog = Win32::OLE->new("COMAdmin.COMAdminCatalog"); my $COMApps = $COMCatalog->GetCollection("Applications"); $COMApps->Populate(); my $COMComponent; for(my $counter = 0; $counter <= %$COMApps->{'count'}; $counter++){ $COMComponent = $COMApps->Item($counter); print "Component: $COMComponent Param Name: $comAppName Com Name: ".$COMComponent->{'Name'}."\n" if(DEBUG); last if($COMComponent->{'Name'} eq $comAppName); } # Check to see if we found the component if($COMComponent->{'Name'} eq $comAppName){ print "\nFound component $COMComponent\n" if(DEBUG); $COMComponent->LetProperty("Identity", $varUserStr); $COMComponent->LetProperty("Password", $varPasswordStr); $COMApps->SaveChanges(); print "Identity: ".$COMComponent->Value("Identity")."\n"; print "Password: ".$COMComponent->Value("Password")."\n"; } I don't get any errors when I run this but the identity/password doesn't change, stays the default of Interactive User. When I run the following vbscript it works: '--- --- ' Install COM+ Components '--- --- Dim i Dim Catalog Set Catalog = CreateObject("COMAdmin.COMAdminCatalog") Dim Applications Set Applications = Catalog.GetCollection("Applications") Applications.Populate Dim CoreApp For i = 0 To Applications.Count - 1 Set CoreApp = Applications.Item(i) If CoreApp.Name = "COMName" Then Exit For End If Next '// ' Apply config settings to the COM+ application '// CoreApp.Value("Identity") = "test" CoreApp.Value("Password") = "test" Applications.SaveChanges Thanks for any help! ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: LWP
Steve, You need to create the "http_proxy" environment variable or do something like this: my $ua = LWP::UserAgent->new; $ua->proxy(['http', 'ftp'], 'http://my.proxy_server.net:3128/'); Read this for more info: http://search.cpan.org/~gaas/libwww-perl-5.79/lib/LWP/UserAgent.pm HTH, James. steve silvers wrote: I have a snippet below that I want to grab content from a website, but I need to get through my proxy server. How can this be done? #!/Perl use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new(GET => 'http://whereever.com'); $req->authorization_basic('user', 'pass'); print $ua->request($req)->as_string; Thanks in advance Steve _ Check out the coupons and bargains on MSN Offers! http://youroffers.msn.com ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Win32 OLE modification of component identity
After a LetProperty, don't you have to do a SetInfo ? That would make sense about why the application doesn't change anyway -- the change wasn't committed to the $COMComponent object. Steven -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Miguel Laborde Sent: Monday, May 03, 2004 11:04 AM To: [EMAIL PROTECTED] Subject: Win32 OLE modification of component identity Hello all, I'm having some trouble modifying the identity/password for a COM+ component using Win32::OLE to do it. I've tried changing it using VBScript and it works fine, however I want this to be done in perl as its part of a suite of other perl utilities I'm working on. Here is the code I'm using. my $comAppName = 'COMName'; my $varUserStr = 'test'; my $varPasswordStr = 'test'; my $COMCatalog = Win32::OLE->new("COMAdmin.COMAdminCatalog"); my $COMApps = $COMCatalog->GetCollection("Applications"); $COMApps->Populate(); my $COMComponent; for(my $counter = 0; $counter <= %$COMApps->{'count'}; $counter++){ $COMComponent = $COMApps->Item($counter); print "Component: $COMComponent Param Name: $comAppName Com Name: ".$COMComponent->{'Name'}."\n" if(DEBUG); last if($COMComponent->{'Name'} eq $comAppName); } # Check to see if we found the component if($COMComponent->{'Name'} eq $comAppName){ print "\nFound component $COMComponent\n" if(DEBUG); $COMComponent->LetProperty("Identity", $varUserStr); $COMComponent->LetProperty("Password", $varPasswordStr); $COMApps->SaveChanges(); print "Identity: ".$COMComponent->Value("Identity")."\n"; print "Password: ".$COMComponent->Value("Password")."\n"; } I don't get any errors when I run this but the identity/password doesn't change, stays the default of Interactive User. When I run the following vbscript it works: '--- --- ' Install COM+ Components '--- --- Dim i Dim Catalog Set Catalog = CreateObject("COMAdmin.COMAdminCatalog") Dim Applications Set Applications = Catalog.GetCollection("Applications") Applications.Populate Dim CoreApp For i = 0 To Applications.Count - 1 Set CoreApp = Applications.Item(i) If CoreApp.Name = "COMName" Then Exit For End If Next '// ' Apply config settings to the COM+ application '// CoreApp.Value("Identity") = "test" CoreApp.Value("Password") = "test" Applications.SaveChanges Thanks for any help! ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Win32 OLE modification of component identity
Hello all, I'm having some trouble modifying the identity/password for a COM+ component using Win32::OLE to do it. I've tried changing it using VBScript and it works fine, however I want this to be done in perl as its part of a suite of other perl utilities I'm working on. Here is the code I'm using. my $comAppName = 'COMName'; my $varUserStr = 'test'; my $varPasswordStr = 'test'; my $COMCatalog = Win32::OLE->new("COMAdmin.COMAdminCatalog"); my $COMApps = $COMCatalog->GetCollection("Applications"); $COMApps->Populate(); my $COMComponent; for(my $counter = 0; $counter <= %$COMApps->{'count'}; $counter++){ $COMComponent = $COMApps->Item($counter); print "Component: $COMComponent Param Name: $comAppName Com Name: ".$COMComponent->{'Name'}."\n" if(DEBUG); last if($COMComponent->{'Name'} eq $comAppName); } # Check to see if we found the component if($COMComponent->{'Name'} eq $comAppName){ print "\nFound component $COMComponent\n" if(DEBUG); $COMComponent->LetProperty("Identity", $varUserStr); $COMComponent->LetProperty("Password", $varPasswordStr); $COMApps->SaveChanges(); print "Identity: ".$COMComponent->Value("Identity")."\n"; print "Password: ".$COMComponent->Value("Password")."\n"; } I don't get any errors when I run this but the identity/password doesn't change, stays the default of Interactive User. When I run the following vbscript it works: '-- ' Install COM+ Components '-- Dim i Dim Catalog Set Catalog = CreateObject("COMAdmin.COMAdminCatalog") Dim Applications Set Applications = Catalog.GetCollection("Applications") Applications.Populate Dim CoreApp For i = 0 To Applications.Count - 1 Set CoreApp = Applications.Item(i) If CoreApp.Name = "COMName" Then Exit For End If Next '// ' Apply config settings to the COM+ application '// CoreApp.Value("Identity") = "test" CoreApp.Value("Password") = "test" Applications.SaveChanges Thanks for any help! ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: To search for a particular file in root drive
Mahajan Alok wrote: > > Thanks a lot for your valuable suggestions.But still the problem is there. > If i use: > # > if (-d) { > $File::Find::prune = 1; > } > ## > IT is simply coming out of the sub routine after this statement and the elsif is not > executed. > > Can you run this script by creating a dummy 71up_exe file? > > Please suggest. My apologies. I had forgotten that the first call to the 'wanted' routine is for the root directory of the tree to be scanned by File::Find, so pruning at this point will discard everything! This version of searchfile() should be correct. Also note that the line that read print "File //$client/C\$/$found found\n"; should be just print "File $found found\n"; HTH, Rob sub searchfile { if (-d) { $File::Find::prune = 1 unless $_ eq '.'; } return if $found; if ( -f and /_up\.exe$/i ) { $found = $File::Find::name; } } ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Reading registry values on IIS server
Now this is an interesting one... I am running my perl code on an IIS server under Windows XP Pro. I want to read the ProxyServer setting from the system registry and have used: use LWP::UserAgent::ProxyAny;my $ua = LWP::UserAgent::ProxyAny->new;$ua->set_proxy_by_name("Default"); Which should work to let me talk to the internet using the default Internet Explorer proxy settings. However, the module is unable to read the system registry key: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer This does contain the correct value on my system (127.0.0.1:5400) I have tried giving the IIS Server permissions to read the registry values stored in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings by right clicking on the folder in RegEdit, going to Permissions and adding IUSR_ to the list. I have tried settings for Full Permissions and Read, but all to no avail. The LWP::UserAgent@@ProxyAny still reports that: "The system could not find the environment option that was entered" ANy ideas on this - I know it is down to the permissions settings somewhere - presumably a server cannot access the registry?? --Rich Mellor RWAP Services35 Chantry Croft, Kinsley, Pontefract, West Yorkshire, WF9 5JHTEL: 01977 610509Visit our website at URL:http://www.rwapsoftware.co.ukStuck with ordinary dial up internet connection ?? Read our review of internet accelerators and broadband at:URL: http://www.rwapadventures.com/Services/reviews.html ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: To search for a particular file in root drive
Alok Mahajan wrote: > > This is my first mail to this group, though i'm just a beginner for PERL. > My problem is that i want to search for a particular file by using FILE::Find > from the C drive only for a list of client m/c which are running on > Windows2000. But this program searches whole of the system and is consuming > too much time. > > Can someone suggest: > 1. How to search a file only from the root(c:\drive)? > 2. How Can i move to other client as soon as i found a particular file from >one client? > > > ##Following is the script used: > > use strict; > use warnings; > use File::Find; > my $clients = "compute1"; > #system("cls"); > > #To check wheteher the client is online. > if (-e "//$clients/C\$"){ > > find (\&searchfile, "//$clients/C\$/"); >sub searchfile { > > if(/_up.exe$/i) > { >if (-f $File::Find::name) { > my $found = $File::Find::name; > print "Found $found"; > unlink $found; > } > else {print " No file found\n";} > } > } > } > else {"print Client Not found\n";} Hi Alok. I've changed the way your code works a little bit: I hope that's OK. The File::Find module isn't really meant for just scanning a single directory (that's easy enough to do with glob() or readdir()) it's meant for scanning an entire directory tree, which isn't quite so easy but is something you often need to do. However, since you want to write it that way I'll show you how. Whenever the 'wanted' subroutine is called and $File:::Find::name is a directory, you can set the $File::Find::prune to a true value to stop File::Find from descending into that directory in its scan. My codes sets it to true for any directory at all so the files scanned will be in only the root directory. Before calling find() the calling code sets scalar $found to a false value (undef). When searchfile() sees any regular file called *_up.exe (you need to escape the dot within a regex) $found is set to the full file name. After a matching file is found ($name is true) the subroutine simply returns whenever it is called as there's no way of stopping File::Find from processing the remainder of the files. After the call to find() the calling code checks the value of $found to and prints a message to say whether a file was found for that client. The enclosing 'foreach' just repeats the process for every client machine in the list. I hope this helps, Rob use strict; use warnings; use File::Find; my @client = qw/ compute1 compute2 compute3 compute4 /; my $found; foreach my $client (@client) { # Check whether the client is online. # if ( -e "//$client/C\$" ) { undef $found; find (\&searchfile, "//$client/C\$/"); if ($found) { print "File //$client/C\$/$found found\n"; unlink $found or warn "Unable to delete $found: $!"; } else { print "No file found for client $client\n"; } } else { print "Client $client not found\n"; } } sub searchfile { return if $found; if (-d) { $File::Find::prune = 1; } elsif ( -f and /_up\.exe$/i ) { $found = $File::Find::name; } } ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
To search for a particular file in root drive
Hi All, This is my first mail to this group, though i'm just a beginner for PERL. My problem is that i want to search for a particular file by using FILE::Find from the C drive only for a list of client m/c which are running on Windows2000. But this program searches whole of the system and is consuming too much time. Can someone suggest: 1. How to search a file only from the root(c:\drive)? 2. How Can i move to other client as soon as i found a particular file from one client? ##Following is the script used: use strict; use warnings; use File::Find; my $clients = "compute1"; #system("cls"); #To check wheteher the client is online. if (-e "//$clients/C\$"){ find (\&searchfile, "//$clients/C\$/"); sub searchfile { if(/_up.exe$/i) { if (-f $File::Find::name) { my $found = $File::Find::name; print "Found $found"; unlink $found; } else {print " No file found\n";} } } } else {"print Client Not found\n";} Waiting for your valuable suggestions. Regards, Alok Mahajan ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs