Solved

Can't Call Method

Posted on 2009-05-11
10
664 Views
Last Modified: 2013-11-05
Trying to install this PERL app on my Win32 box.  Some of you may have heard of it, its called ASSP.

Anyhow, I am no PERL developer.  When I run this command at command prompt I am presented with this error:

Can't Call Method "GetValue" on an undefined value

Errors out on this line:
$ENV{HTTP_proxy} = $rkey->GetValue( "ProxyServer" );
if (-e "$asspdir\\assp.cfg") {
        print "reading proxy settings from assp.cfg\n";
        open(CFG,"<$asspdir\\assp.cfg"); local $/; (%Config)=split(/:=|\n/,<CFG>); close CFG;
        $ENV{HTTP_proxy} = $Config{proxyserver} if ($Config{proxyserver} && ! $ENV{HTTP_proxy});
    } else {
        if ($^O eq "MSWin32" && ! $ENV{HTTP_proxy}) {
            my $rkey;
            my $Registry;
            print "reading IE proxy settings from windows-registry\n";
            eval("use Win32::TieRegistry ( Delimiter=>'/', ArrayValues=>1 );");
            $rkey=$Registry->{'CUser/Software/Microsoft/Windows/CurrentVersion/Internet Settings'};
            if (unpack("N", pack("H8", substr($rkey->GetValue( "ProxyEnable" ), -8)))) {
                $ENV{HTTP_proxy} = $rkey->GetValue( "ProxyServer" );
            }
        }
    }

Open in new window

0
Comment
Question by:chrisryhal
  • 5
  • 3
  • 2
10 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 24359977
that would suggest that
   $Registry->{'CUser/Software/Microsoft/Windows/CurrentVersion/Internet Settings'}
returned undef
but then $rkey->GetValue( "ProxyEnable" ) should have given an error
0
 
LVL 2

Author Comment

by:chrisryhal
ID: 24360053
Your probably correct, my count of lines was incorrect.  Any ideas what may be throwing this?
0
 
LVL 2

Author Comment

by:chrisryhal
ID: 24360063
If it helps and if this is what I am thinking, I do not have a proxy setup on this server nor is anything running through proxy.  Its pretty much a virgin server at this point.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 84

Expert Comment

by:ozo
ID: 24360086
do you define $Registry anywhere?
0
 
LVL 2

Author Comment

by:chrisryhal
ID: 24360107
I have no idea what that is.  This script is in its raw from the developer, so I guess the answer might be no?
0
 
LVL 25

Expert Comment

by:lwadwell
ID: 24360136
Hi chrisryhal,

Just to double check, do you have the package Win32::TieRegistry installed as part of your perl setup?  This package is setting up the $Registry variable - it contains a tie to your registry values.

Do you have the 'ProxyEnable' in your registry? (within HKEY_CURRENT_USER->Software/Microsoft/Windows/CurrentVersion/Internet Settings)

lwadwell
0
 
LVL 2

Author Comment

by:chrisryhal
ID: 24360160
TieRegistery is not installed.  Should I install it?  I can do so.
0
 
LVL 25

Expert Comment

by:lwadwell
ID: 24360175
chrisryhal,

Two choices ...
1. Yes, install it.
2. Set up an environment variable called HTTP_proxy to contain your proxy server details (if any) and it will be used in preference to getting it from your registry (if ($^O eq "MSWin32" && ! $ENV{HTTP_proxy})).

lwadwell
0
 
LVL 2

Author Comment

by:chrisryhal
ID: 24363448
I'm using the ActivePerl latest build which is 5.10.  Appears that Win32-Http_Proxy was already installed and configured using the Perl Package Manager.   So I'm good there.

When creating the Windows Environmental Variable what should I make the default value since I have no proxy?  If I just leave it blank, it doesn't appear to save.
0
 
LVL 25

Accepted Solution

by:
lwadwell earned 500 total points
ID: 24370744
Hi,

By ASSP do you mean Anti-Spam SMTP Proxy (ASSP) Server?  I had a look through its code and could not find the code you supplied above.  

Anyway ... my reading of the code above is ...

1. Line below checks if a config file exists ... if so, use it.  If not, continue to step 2 below. Q. do you have a config file?  How is the variable $asspdir being set to point to its location?  
if (-e "$asspdir\\assp.cfg") { ##

2. Line below tests if this in a Win32 machins and if the env variable HTTP_proxy does not exist.  If the env variable exists it will already be in $ENV.  If not, continue to step 3 below.  As you cannot store a 'blank' value I do not know what would be a valid alternative (... perhaps 'localhost' or the machines IP ... or even a single space char ... not sure).
        if ($^O eq "MSWin32" && ! $ENV{HTTP_proxy}) {

3. The lnes below will use the perl package Win32-TieRegistry to obtain the proxy values from the Internet Explorer proxy settings from the registry.
            my $rkey;
            my $Registry;
            print "reading IE proxy settings from windows-registry\n";
            eval("use Win32::TieRegistry ( Delimiter=>'/', ArrayValues=>1 );");
            $rkey=$Registry->{'CUser/Software/Microsoft/Windows/CurrentVersion/Internet Settings'};
            if (unpack("N", pack("H8", substr($rkey->GetValue( "ProxyEnable" ), -8)))) {
                $ENV{HTTP_proxy} = $rkey->GetValue( "ProxyServer" );

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
perl to display a matrix report for 3-dimenional array 3 71
Transforming a Soap message to a simple xml message! 10 150
Using Perl DBI to query oracle 3 46
perl syntax 3 16
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question