Solved

Can't Call Method

Posted on 2009-05-11
10
633 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
 
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now