Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Running Win32::OLe on Remote machine

by nisha (Sexton)
on May 23, 2006 at 08:45 UTC ( [id://551100]=perlquestion: print w/replies, xml ) Need Help??

nisha has asked for the wisdom of the Perl Monks concerning the following question:

Dear Perl Monks, I have a strange problem, my requirement is to push scripts to a remote machine and the script should start running on that remote machine. inorder to push the files to the remote machine i am using a freeware tool BeyondExecv2.exe. The bat file and the script which would run is pasted below:
In start.bat c:\perl\bin perl c:\sendeicar.pl in sendeicar.pl my $notes = Win32::OLE->new('Notes.NotesSession') or die "Error :Canno +t start Notes Session $!";
I just have one line which would open the Lotus Notes on the remote machine, to read mails etc. When i copy the script manually to the remote machine and execute start.bat, the script works fine and opens lotus notes. When i try running the same script from the server which inturn would initiate a run on the client machine i get the following error "Error: Cannot start Notes session, Bad file descriptor at NotesSession.pm line 7". I am unable to figure out why this is happening, Please do help me because i am badly stuck because of this problem. Thanks, Nisha

Replies are listed 'Best First'.
Re: Running Win32::OLe on Remote machine
by gellyfish (Monsignor) on May 23, 2006 at 09:07 UTC

    You can do DCOM operations with Win32::OLE, you just have to specify the host you want to activate the object on: from the Win32::OLE documentation:

    To create an object via DCOM on a remote server you can use an array reference in place of PROGID. The referenced array must contain the machine name and the program id or class id. For example:

    my $obj = Win32::OLE->new(['my.machine.com', 'Program.Id']);

    If the PROGID is a program id then Win32::OLE will try to resolve the corresponding class id locally. If the program id is not registered locally then the remote registry is queried. This will only succeed if the local process has read access to the remote registry. The safest (and fastest) method is to specify the class id directly.

    As well as having the appropriate permissions to read the registry on the remote machine you also will need to set up the application security and identity on the remote machine using the dcomcnfg utility. It is important that you set the 'Identity' (i.e. the user that the remote application is run as) to one that has access to the appropriate resources for the application to run; you should also bear in mind that with COM activation the users default registry hive is not loaded so if you need access to settings stored in the users registry that user will need to be logged in to an interactive session on the machine, an alternative that I have used in the past is to create a dummy service that runs on the machine as the appropriate user, this will cause the registry hive to be kept open.

    There are a lot of articles on MSDN about this for your further reading.

    Update: another thing I forgot to point out is that you don't want to use $! to get the error message from the Win32::OLE but should use the Win32::OLE->LastError() class method as described in the documentation.

    /J\

Re: Running Win32::OLe on Remote machine
by EdwardG (Vicar) on May 23, 2006 at 09:13 UTC

    Check the security context (ie login account) in which your batch + script runs on the remote machine. It might be different to your manual test.

    Apparently, you can start a command session on the remote machine, so you could check security context this way.

    C:\>beyondexec \\neptune BeyondExec V2.05 - Spawn Remote Processes on Windows NT/2000/XP WorkSt +ations. Copyright(C) 2002-2003 Craig.Peacock@beyondlogic.org [neptune] BeyondExec service already installed on remote machine. [neptune] Command Successfully Issued to neptune on Pipe 1. [neptune] Process started, ProcessID = 1444, ThreadID = 1440 Microsoft Windows 2000 [Version 5.00.2195] (C) Copyright 1985-2000 Microsoft Corp. C:\Winnt\System32>whoami (or net view, etc) etc...

     

Re: Running Win32::OLe on Remote machine
by marto (Cardinal) on May 23, 2006 at 09:07 UTC
    nisha,

    If you are saying that your script works when you run it on the remote server, then I don't think this is a Perl issue. Perhaps you are not using BeyondExecv2.exe in the way you should. Is this one line of Perl code the entire script? I notice that the error message reports that this is on line 7 of the script. Perhaps if you provided the syntax you are executing BeyondExecv2.exe with, someone may be able to help you.

    Hope this helps.

    Martin

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://551100]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2024-04-16 19:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found