Solved

Can't Call Method

Posted on 2009-05-11
10
682 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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…
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…
Six Sigma Control Plans

617 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