RE: Resolved - Question about Win32::OLE
Title: RE: Resolved - Question about Win32::OLE After screwing up the last two days, I now have this well embedded in my mind. Wel, at least until I have another memory dump. This list is a great resource. Best to all, Sturdy > -Original Message- > From: Timothy Johnson [mailto:[EMAIL PROTECTED]] > Sent: Thursday, May 25, 2006 5:00 PM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Cc: perl-win32-users@listserv.ActiveState.com > Subject: RE: Resolved - Question about Win32::OLE > > I think that's what most of us were getting at. In order for your "or" > conditions to be tripped you would have to get something back that did not > evaluate to false. In the case of a function that is returning positive > numbers for error codes, there is about a 99% chance that it is returning > 0 on success. > > > > > From: [EMAIL PROTECTED] [mailto:perl- > [EMAIL PROTECTED] On Behalf Of > [EMAIL PROTECTED] > Sent: Thursday, May 25, 2006 8:15 AM > To: [EMAIL PROTECTED] > Cc: perl-win32-users@listserv.ActiveState.com > Subject: RE: Resolved - Question about Win32::OLE > > Hi Nick, > > Take a look at the API doc for whatever SFTP program you are accessing; > > it may be returning values you are not expecting. After you instantiate > > via the new method in OLE you are passed back whatever the external > > program passes back. It could be passing back 0 upon success which will > > cause die to work azz-backwards. > That's a good point and may be the issue. Unfortunately, the API doc only > provides vbs examples with little added info, no return value info, etc. > However, I did drop an email to the company. No response yet. > Thanks, > Sturdy ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Resolved - Question about Win32::OLE
This isn't really a Win32::OLE issue. There are two different philosophies when it comes to returning success or error from a function: 1. The kind of function you run into most frequently in Perl is the kind that will return a "false" value on error (usually 0), and a "true" value on success (usually either 1 or whatever data you were requesting). 2. The second kind of function is less often seen in Perl, but it acts the way most programs do. These functions return 0 on success, and return an error code on failure. The problem is that if you run into these, you can't use the "function() or die;" semantics people are used to because the "or" part of the statement will be executed on success instead of failure. If you change your line to be !$SFTPServer->connect( $Server, $Port, $UserName, $Password ) or die "Could not connect as $UserName to $Server:$Port!"; you might get the results you wanted. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, May 25, 2006 6:23 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; Timothy Johnson; [EMAIL PROTECTED] Cc: perl-win32-users@listserv.ActiveState.com Subject: Resolved - Question about Win32::OLE First, thanks to all who offered their assistance. I spent many hours trying to make my simple test script work...and it does (did)! Darn thing had been working all the time (very embarassing). The problem seems to be die or warn in this line: $SFTPServer->connect( $Server, $Port, $UserName, $Password ) or die "Could not connect as $UserName to $Server:$Port!"; This line does not cause the error message. $SFTPServer->connect( $Server, $Port, $UserName, $Password ); Apparently, both versions were actually making a connection while I thought it was failing because of the message. I'm guessing that die/warn should not be used with win32::OLE. LastError seems the correct construct. Again, thanks to all Sturdy ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Resolved - Question about Win32::OLE
I think that's what most of us were getting at. In order for your "or" conditions to be tripped you would have to get something back that did not evaluate to false. In the case of a function that is returning positive numbers for error codes, there is about a 99% chance that it is returning 0 on success. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Thursday, May 25, 2006 8:15 AM To: [EMAIL PROTECTED] Cc: perl-win32-users@listserv.ActiveState.com Subject: RE: Resolved - Question about Win32::OLE Hi Nick, > Take a look at the API doc for whatever SFTP program you are accessing; > it may be returning values you are not expecting. After you instantiate > via the new method in OLE you are passed back whatever the external > program passes back. It could be passing back 0 upon success which will > cause die to work azz-backwards. That's a good point and may be the issue. Unfortunately, the API doc only provides vbs examples with little added info, no return value info, etc. However, I did drop an email to the company. No response yet. Thanks, Sturdy ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Resolved - Question about Win32::OLE
Title: RE: Resolved - Question about Win32::OLE Hi Nick, > Take a look at the API doc for whatever SFTP program you are accessing; > it may be returning values you are not expecting. After you instantiate > via the new method in OLE you are passed back whatever the external > program passes back. It could be passing back 0 upon success which will > cause die to work azz-backwards. That's a good point and may be the issue. Unfortunately, the API doc only provides vbs examples with little added info, no return value info, etc. However, I did drop an email to the company. No response yet. Thanks, Sturdy ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Resolved - Question about Win32::OLE
Take a look at the API doc for whatever SFTP program you are accessing; it may be returning values you are not expecting. After you instantiate via the new method in OLE you are passed back whatever the external program passes back. It could be passing back 0 upon success which will cause die to work azz-backwards. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, May 25, 2006 9:23 AM To: [EMAIL PROTECTED]; Bharucha, Nikhil; [EMAIL PROTECTED]; [EMAIL PROTECTED] Cc: perl-win32-users@listserv.ActiveState.com Subject: Resolved - Question about Win32::OLE First, thanks to all who offered their assistance. I spent many hours trying to make my simple test script work...and it does (did)! Darn thing had been working all the time (very embarassing). The problem seems to be die or warn in this line: $SFTPServer->connect( $Server, $Port, $UserName, $Password ) or die "Could not connect as $UserName to $Server:$Port!"; This line does not cause the error message. $SFTPServer->connect( $Server, $Port, $UserName, $Password ); Apparently, both versions were actually making a connection while I thought it was failing because of the message. I'm guessing that die/warn should not be used with win32::OLE. LastError seems the correct construct. Again, thanks to all Sturdy ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs