Solved

Can't Call Method

Posted on 2009-05-11
10
656 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Which version of C should I use when Perl is too slow? 13 181
Perl script not writing to .csv file 6 109
Awk Question 2 127
Perl modules on linux ec2 3 104
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

770 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