[24514] in Perl-Users-Digest
Perl-Users Digest, Issue: 6694 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 15 18:05:47 2004
Date: Tue, 15 Jun 2004 15:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 15 Jun 2004 Volume: 10 Number: 6694
Today's topics:
[PERL] internal server error (Nicolas D)
Re: [PERL] internal server error <ittyspam@yahoo.com>
Re: ActivePerl and Expect question (Bill)
Arjen Jongeling, een oude bekende <noem@il.com>
Array of functions w/arguments? <dkoleary@olearycomputers.com>
Re: Array of functions w/arguments? <ebohlman@omsdev.com>
Re: Array of functions w/arguments? (Greg Bacon)
Re: Array of functions w/arguments? <perl@my-header.org>
Re: Array of functions w/arguments? <dkoleary@olearycomputers.com>
Re: Array of functions w/arguments? <dkoleary@olearycomputers.com>
Re: call win32 API from linux perl script <ceo@nospan.on.net>
Class method call fails - "unblessed reference" <MyFirstnameHere.News1@gustra.org>
Re: enlarge Variablenames <Andrew@DeFaria.com>
Re: Howto capture interactive SQL*Plus session info on <usenet@morrow.me.uk>
Re: Howto capture interactive SQL*Plus session info on <wolfphaedrus@hotmail.com>
Re: Howto capture interactive SQL*Plus session info on <wolfphaedrus@hotmail.com>
Mail::POP3Client <a.ymous3@btinternet.com>
Re: Mail::POP3Client <usenet@morrow.me.uk>
Re: OLE, WMI and ExecMethod - possible? <Petri_member@newsguy.com>
Re: parsing file name assigning extension to a variable (Alexander Heimann)
Re: parsing file name assigning extension to a variable <gnari@simnet.is>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Jun 2004 09:42:04 -0700
From: nico99@netcourrier.com (Nicolas D)
Subject: [PERL] internal server error
Message-Id: <7fe6c964.0406150842.440520b0@posting.google.com>
Hello,
I tried my perl scrip on my localhost and it' s OK.
When i upload it on a web server with perl interprer, i have "INTERNAL
SERVOR ERROR", i used chomp 755 for the files.cgi and its directory ,
i have the good path in the program begining . So what's the problem ?
Thanks
Nicolas DAOUT
------------------------------
Date: Tue, 15 Jun 2004 13:10:11 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: [PERL] internal server error
Message-Id: <20040615130753.V20623@dishwasher.cs.rpi.edu>
On Tue, 15 Jun 2004, Nicolas D wrote:
> Hello,
>
> I tried my perl scrip on my localhost and it' s OK.
> When i upload it on a web server with perl interprer, i have "INTERNAL
> SERVOR ERROR", i used chomp 755 for the files.cgi and its directory ,
> i have the good path in the program begining . So what's the problem ?
There could be any number of problems. First, did you check the error log
of your server? That will tell you exactly what the server error is.
Second, did you read the FAQ on this topic?
perldoc -q server
Third, you may want to consider adding the following lines to the top of
your CGI program:
use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
warningsToBrowser(1);
This will cause any perl compilation errors to be displayed on the
browser, rather than only on the server logs.
Paul Lalli
------------------------------
Date: 15 Jun 2004 10:40:50 -0700
From: wherrera@lynxview.com (Bill)
Subject: Re: ActivePerl and Expect question
Message-Id: <239ce42f.0406150940.7309f657@posting.google.com>
dipakprasad@hotmail.com (Dipak Prasad) wrote in message news:<6ab178e3.0406110553.41658947@posting.google.com>...
> Hi
>
> I have a question regarding ActivePerl and Expect. I am working with
> already existing ActivePerl (5.6.1 Build 635) s/w for Windows. I need
> to integrate and automate an interactive CLI-Menu driven 3rd party s/w
> to the ActivePerl s/w. I was planning to do that using Expect, when I
> found out that Expect is not supported by ActivePerl. My question is
> there something equivalent to Expect provided by ActivePerl (I have
> never used Active Perl before), and/or is there a way to make Expect
> work with ActivePerl?
>
> Thank
Never used it, but look at
http://www.activestate.com/Products/Expect/
------------------------------
Date: Tue, 15 Jun 2004 18:25:47 +0200
From: Arjen Jongeling<noem@il.com>
Subject: Arjen Jongeling, een oude bekende
Message-Id: <40cf231d_3@127.0.0.1>
Hoewel, Arjen Jongeling is hier nog nooit geweest en ik denk dat Arjen Jongeling hier ook nooit meer zal terugkomen. Sterker nog, Arjen Jongeling zit hier helemaal fout. Maar ja, het doet het goed in de Google archieven.
------------------------------
Date: Tue, 15 Jun 2004 17:15:17 GMT
From: Doug O'Leary <dkoleary@olearycomputers.com>
Subject: Array of functions w/arguments?
Message-Id: <F8Gzc.5640$7Y.3305@fe07.usenetserver.com>
Hey, all;
I'm working on a fairly complex script which could be a little
less complex if I could have used an array of function references.
Unfortunately, I needed to be able to send different arguments to
some of the functions. I ended up working around the issue so it's
more a matter of curiousity than anything else but I'm hoping to
see if there's a good way to do what I was looking to do:
Here's what I had:
#######################################################
@funcs = (sub{print "\n\nUser: "; $user = <STDIN>; chomp $user;},
sub {$lock++; $lock = 0 if ($lock == 2); },
\&get_passwd,
\&get_hdpw,
sub {$force++; $force = 0 if ($force == 2);},
\&select_systems
);
my $func_return = $funcs[$choice];
#######################################################
If it were just that, things would work great. Unfortunately,
get_passwd(), for instance, needs $user for an argument,
get_hdpw() needs $hduser; select_systems takes a reference to
an array as an argument.
There were others, but that gets the point across.
Any way to use an array of function references and allow for
different arguments? Any better ways to do something similar?
Thanks for any hints/tips/suggestions.
Doug
--
--------
Senior UNIX Admin
O'Leary Computer Enterprises
dkoleary@olearycomputers.com (w) 630-904-6098 (c) 630-248-2749
resume: http://www.olearycomputers.com/resume.html
------------------------------
Date: 15 Jun 2004 17:41:27 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: Array of functions w/arguments?
Message-Id: <Xns950981CD610EFebohlmanomsdevcom@130.133.1.4>
Doug O'Leary <dkoleary@olearycomputers.com> wrote in
news:F8Gzc.5640$7Y.3305@fe07.usenetserver.com:
> I'm working on a fairly complex script which could be a little
> less complex if I could have used an array of function references.
>
> Unfortunately, I needed to be able to send different arguments to
> some of the functions. I ended up working around the issue so it's
> more a matter of curiousity than anything else but I'm hoping to
> see if there's a good way to do what I was looking to do:
>
> Here's what I had:
>
> #######################################################
> @funcs = (sub{print "\n\nUser: "; $user = <STDIN>; chomp $user;},
> sub {$lock++; $lock = 0 if ($lock == 2); },
> \&get_passwd,
> \&get_hdpw,
> sub {$force++; $force = 0 if ($force == 2);},
> \&select_systems
> );
>
> my $func_return = $funcs[$choice];
> #######################################################
>
> If it were just that, things would work great. Unfortunately,
> get_passwd(), for instance, needs $user for an argument,
> get_hdpw() needs $hduser; select_systems takes a reference to
> an array as an argument.
>
> There were others, but that gets the point across.
>
> Any way to use an array of function references and allow for
> different arguments? Any better ways to do something similar?
You might want to look at how HTML::Parser handles the related issue of
letting you define what arguments various callback subs should be called
with. Or the (different) way Perl/Tk lets you associate commands with
widgets. That's assuming you want a fairly general mechanism: if you're
really only interested in the exact dispatch table you listed above, all
you'd have to do is change it to:
@funcs = (sub{print "\n\nUser: "; $user = <STDIN>; chomp $user;},
sub {$lock++; $lock = 0 if ($lock == 2); },
sub {get_passwd($user);},
sub {get_hdpw($hduser);},
sub {$force++; $force = 0 if ($force == 2);},
sub {select_systems($reference_to_appropriate_array);}
> );
There's no reason you can't call a named sub from within an anonymous sub.
------------------------------
Date: Tue, 15 Jun 2004 17:42:48 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Array of functions w/arguments?
Message-Id: <10cud8o8j95mea4@corp.supernews.com>
In article <F8Gzc.5640$7Y.3305@fe07.usenetserver.com>,
Doug O'Leary <dkoleary@olearycomputers.com> wrote:
: Unfortunately, I needed to be able to send different arguments to
: some of the functions. I ended up working around the issue so it's
: more a matter of curiousity than anything else but I'm hoping to
: see if there's a good way to do what I was looking to do:
:
: [...]
:
: If it were just that, things would work great. Unfortunately,
: get_passwd(), for instance, needs $user for an argument,
: get_hdpw() needs $hduser; select_systems takes a reference to
: an array as an argument.
You could make @funcs be an array of closures, creating wrappers where
necessary:
$ cat try
#! /usr/local/bin/perl
use warnings;
use strict;
use Data::Dumper;
sub get_passwd {
my $user = shift;
print "get_passwd: \$user = [$user]\n";
}
sub get_hdpw {
my $hduser = shift;
print "get_hdpw: \$hduser = [$hduser]\n";
}
sub select_systems {
my $array = shift;
local $Data::Dumper::Indent = 1;
print "select_systems: ",
Data::Dumper->Dump([$array], ['array']);
}
## main
my $lock = 0;
my $force = 0;
my $user;
my $hduser = "resudh";
my @array = qw/ apple orange banana /;
my @funcs = (
sub {
chomp($user = <DATA>);
print "\n\nUser: $user\n";
},
sub {
$lock++;
$lock = 0 if $lock == 2;
print "lock = $lock\n";
},
sub { get_passwd $user },
sub { get_hdpw $hduser },
sub {
$force++;
$force = 0 if $force == 2;
print "force = $force\n";
},
sub { select_systems \@array },
);
foreach my $f (@funcs) {
$f->();
}
__DATA__
luser
$ ./try
User: luser
lock = 1
get_passwd: $user = [luser]
get_hdpw: $hduser = [resudh]
force = 1
select_systems: $array = [
'apple',
'orange',
'banana'
];
$
Hope this helps,
Greg
--
Indeed, the Good Book enjoins me to pray for all those in authority; and
we all know what that prayer is: "Lord, please turn them all into
Libertarians. Amen!".
-- Roland Watson
------------------------------
Date: Tue, 15 Jun 2004 19:46:00 +0200
From: Matija Papec <perl@my-header.org>
Subject: Re: Array of functions w/arguments?
Message-Id: <e6duc09vurtsqves2k7aanjn0t35s5e35b@4ax.com>
X-Ftn-To: Doug O'Leary
Doug O'Leary <dkoleary@olearycomputers.com> wrote:
>#######################################################
>@funcs = (sub{print "\n\nUser: "; $user = <STDIN>; chomp $user;},
> sub {$lock++; $lock = 0 if ($lock == 2); },
> \&get_passwd,
> \&get_hdpw,
> sub {$force++; $force = 0 if ($force == 2);},
> \&select_systems
>);
>
>my $func_return = $funcs[$choice];
>#######################################################
>
>If it were just that, things would work great. Unfortunately,
>get_passwd(), for instance, needs $user for an argument,
>get_hdpw() needs $hduser; select_systems takes a reference to
>an array as an argument.
That would be,
get_passwd($user);
or,
$funcs[2]->($user);
via reference.
--
Matija
------------------------------
Date: Tue, 15 Jun 2004 18:38:11 GMT
From: Doug O'Leary <dkoleary@olearycomputers.com>
Subject: Re: Array of functions w/arguments?
Message-Id: <nmHzc.5659$7Y.2848@fe07.usenetserver.com>
In article <Xns950981CD610EFebohlmanomsdevcom@130.133.1.4>, Eric Bohlman wrote:
>
> @funcs = (sub{print "\n\nUser: "; $user = <STDIN>; chomp $user;},
> sub {$lock++; $lock = 0 if ($lock == 2); },
> sub {get_passwd($user);},
> sub {get_hdpw($hduser);},
> sub {$force++; $force = 0 if ($force == 2);},
> sub {select_systems($reference_to_appropriate_array);}
>> );
>
> There's no reason you can't call a named sub from within an anonymous sub.
Perfect! That worked great! Thanks for the tip!
Doug
--
--------
Senior UNIX Admin
O'Leary Computer Enterprises
dkoleary@olearycomputers.com (w) 630-904-6098 (c) 630-248-2749
resume: http://www.olearycomputers.com/resume.html
------------------------------
Date: Tue, 15 Jun 2004 18:40:33 GMT
From: Doug O'Leary <dkoleary@olearycomputers.com>
Subject: Re: Array of functions w/arguments?
Message-Id: <BoHzc.5660$7Y.1267@fe07.usenetserver.com>
In article <10cud8o8j95mea4@corp.supernews.com>, Greg Bacon wrote:
> You could make @funcs be an array of closures, creating wrappers where
> necessary:
[..snip..]
> Hope this helps,
That helped alot! Thank you very much. Much cleaner than the
way I was doing it...
Doug
--
--------
Senior UNIX Admin
O'Leary Computer Enterprises
dkoleary@olearycomputers.com (w) 630-904-6098 (c) 630-248-2749
resume: http://www.olearycomputers.com/resume.html
------------------------------
Date: Tue, 15 Jun 2004 15:24:11 GMT
From: Chris <ceo@nospan.on.net>
Subject: Re: call win32 API from linux perl script
Message-Id: <vwEzc.449$2J7.435@newssvr33.news.prodigy.com>
l v wrote:
> Ben Morrow wrote:
>
>> Quoth broutaf@yahoo.fr (broutard):
>>
>>> I'm must calling an API from a remote win32 server in a perl script.
>>> On a windows server, I use win32::OLE and it's work fine !
>>>
>>> But my perl script must run on a linux server and must call this
>>> win32 API !
>>> Apparently, it's impossible to install win32::OLE on linux.
>>>
>>> So, how can i do ??
>>
>>
>>
>> AFAIK COM+ automation (OLE) doesn't allow you to interact with an object
>> on another machine, so you would have the same problem calling an OLE
>> function on one windows machine from another. What you need to do is set
>> up a perl script that is always running on the Win32 machine, waiting
>> for connections; then, when it receives one, it makes the OLE call and
>> passes the results back to the other end.
>> This sort of setup is called 'RPC' for 'Remote Procedure Call' and there
>> are modules on CPAN which will handle both ends for you, for a variety
>> of standard protocols. Try starting with RPC::Simple or XMLRPC::Lite.
>> If none of these will fit your needs, for whatever reason, you will need
>> to design your own protocol and implement a server for the Win32 box and
>> a client for the linux box. Getting this sort of design right is not the
>> easiest thing in the world, though, so you would be better off using one
>> of the standard modules if you can.
>>
>> Ben
>>
>
> I once did something similar to this however I used http as the listener
> to run the windows perl script. I needed to connect to an ODBC
> connection behind a firewall, port 80 was the only port open. The unix
> server used LWP to *run* the win perl script via http. The sql was
> passed in the url and the results were passed back as pairs of
> "key=value\n" which was quickly stored into a hash. I still had to
> design my own protocol but that was what made the task fun to work on.
>
Could have saved yourself some time and work (and had just as much fun)
using XML-RPC. The protocol is already defined and uses port 80 (HTTP),
which is what it was designed for. This, as Ben Morrow has already
suggested, could be one approach to the OP's problem and one I would
recommend as well (eg. some RPC approach).
-ceo
------------------------------
Date: Tue, 15 Jun 2004 22:06:11 +0200
From: Gunnar Strand <MyFirstnameHere.News1@gustra.org>
Subject: Class method call fails - "unblessed reference"
Message-Id: <cankrq$7s6$1@hudsucker.umdac.umu.se>
Hi,
I am trying to write test cases using Test::Unit, and one of the
test object starts like this:
1 package Test::TestProfileSettings;
2
3 use Cmpm::Profile::Settings;
4 use Test::Unit::TestCase;
5 use base qw( Test::Unit::TestCase );
6
7 sub new {
8 my $class = shift;
9 my $self = $class -> SUPER::new( @_ );
10 return $self;
11 }
12
13 sub test_settings1 {
14 my $self = shift;
15 my $s = Cmpm::Profile::Settings -> new;
16 print STDERR "\$s = $s\n";
...more code below, but this is the only method...
I use a TestSuite to run several test objects. If I run one certain
test case before the one above, then perl complains:
Test/TestProfileSettings.pm:15 - test_settings1(Test::TestProfileSettings)
Can't call method "new" on unblessed reference
It seems odd to me that perl would consider the class name to be
an unblessed reference. If the test cases run in a different order,
then all passes without any errors. Has anyone seen this before,
and has any idea on what could be wrong?
Kind Regards,
/Gunnar
------------------------------
Date: Tue, 15 Jun 2004 14:23:27 -0700
From: "Andrew DeFaria" <Andrew@DeFaria.com>
Subject: Re: enlarge Variablenames
Message-Id: <746e9$40cf68b4$c09cfc9$28691@msgid.meganewsservers.com>
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:4gDzc.46771$TR1.20338@nwrddc01.gnilink.net...
> [Please do not top-post]
> [Please trim the quoted text to a reasonble amout that is needed for
> context]
Also, aren't these top posts? ;-)
Not I whole heartedly agree with Jügen, trim, trim, trim! Way too much
excess is quoted.
------------------------------
Date: Tue, 15 Jun 2004 18:41:44 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Howto capture interactive SQL*Plus session info on Win32?
Message-Id: <canft8$anh$1@wisteria.csv.warwick.ac.uk>
Quoth Gregory Toomey <nospam@bigpond.com>:
> James wrote:
>
> > Hi All,
> > I am trying to capture the output of an Oracle SQL*Plus session
> > into
> > an array but can't find any examples; specifically o retrieve a list of
> > tablespaces. I can get it to log on and run the script but capturing it
> > is
> > a different game entirely. I realise Perl has its own native Oracle DBD
> > module but that won't compile with Perl2exe(at least I can't work out how
> > to). I can have Perl call SQL*Plus with an external script but I'm trying
> > to do without loads of temp sql files. Is this even possible or is a
> > major rethink in order?
> >
> > Thanks in advance for any hints
> > James
>
> Sqlplus just writes to stdout so you can try something like (untested):
>
> open(ORA, "cat 'select * from tableapace;'|sqlplus |")
You mean echo, not cat.
You could also use IPC::Open2.
Ben
--
"If a book is worth reading when you are six, * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis
------------------------------
Date: Tue, 15 Jun 2004 20:30:13 +0100
From: "James" <wolfphaedrus@hotmail.com>
Subject: Re: Howto capture interactive SQL*Plus session info on Win32?
Message-Id: <B6Izc.105168$wd7.95103@front-1.news.blueyonder.co.uk>
Thanks Kevin, I tried that today and it worked!
Cheers
James
"Kevin Michael Vail" <kevin@vaildc.net> wrote in message
news:kevin-CDB989.21460614062004@news.verizon.net...
> In article <mAozc.97273$wd7.58990@front-1.news.blueyonder.co.uk>,
> "James" <wolfphaedrus@hotmail.com> wrote:
>
> > [...] I realise Perl has its own native Oracle DBD
> > module but that won't compile with Perl2exe(at least I can't work out
how
> > to). [...]
>
> I've been doing this for literally years. You need to explicitly add
> the following line in your program somewhere:
>
> use DBD::Oracle;
>
> so that the Perl2Exe program knows to include that module in the
> compiled executable. Other than that there should be no problem.
> --
> Kevin Michael Vail | a billion stars go spinning through the night,
> kevin@vaildc.net | blazing high above your head.
> . . . . . . . . . | But _in_ you is the presence that
> . . . . . . . . | will be, when all the stars are dead.
> . . . . . . . . . | (Rainer Maria Rilke)
------------------------------
Date: Tue, 15 Jun 2004 20:43:50 +0100
From: "James" <wolfphaedrus@hotmail.com>
Subject: Re: Howto capture interactive SQL*Plus session info on Win32?
Message-Id: <mjIzc.105170$wd7.28717@front-1.news.blueyonder.co.uk>
Hi,
This seemed an interesting solution but I think I may have misunderstood:
----------------------------------------------------------------------------
---------------------------------------
#!C:\Perl\bin\perl.exe
open(ORA, "echo 'select tablespace_name from tablespace;'|sqlplus
system/manager\@ORAC.WORLD|") ;
while (<ORA>)
{
print "$_\n";
}
close(ORA) ;
----------------------------------------------------------------------------
---------------------------------------
C:\Perl>ora2.pl
SQL*Plus: Release 9.2.0.1.0 - Production on Tue Jun 15 20:42:52 2004
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
With the Partitioning option
JServer Release 8.1.7.4.0 - Production
SQL> SP2-0734: unknown command beginning "'select ta..." - rest of line
ignored.
SQL> Disconnected from Oracle8i Enterprise Edition Release 8.1.7.4.0 -
Production
With the Partitioning option
JServer Release 8.1.7.4.0 - Production
C:\Perl>
----------------------------------------------------------------------------
---------------------------------------
Have I forgotten something obvious?
"Gregory Toomey" <nospam@bigpond.com> wrote in message
news:10072023.ASMkjmpKEe@GMT-hosting-and-pickle-farming...
> James wrote:
>
> > Hi All,
> > I am trying to capture the output of an Oracle SQL*Plus session
> > into
> > an array but can't find any examples; specifically o retrieve a list of
> > tablespaces. I can get it to log on and run the script but capturing it
> > is
> > a different game entirely. I realise Perl has its own native Oracle
DBD
> > module but that won't compile with Perl2exe(at least I can't work out
how
> > to). I can have Perl call SQL*Plus with an external script but I'm
trying
> > to do without loads of temp sql files. Is this even possible or is a
> > major rethink in order?
> >
> > Thanks in advance for any hints
> > James
>
> Sqlplus just writes to stdout so you can try something like (untested):
>
> open(ORA, "cat 'select * from tableapace;'|sqlplus |")
> while (<ORA>) {
> #processing
> }
> close(ORA)
>
>
> But DBI is by far the preferred solution.
>
> gtoomey
------------------------------
Date: Tue, 15 Jun 2004 16:49:09 +0000 (UTC)
From: A Ymous <a.ymous3@btinternet.com>
Subject: Mail::POP3Client
Message-Id: <40CF2869.EF7BC7BA@btinternet.com>
Is there a way of monitoring the progress of message retrieval when
using Mail::POP3Client? I had a large message to retrieve (>5MB) and
couldn't tell if the message was being retrieved or not.
------------------------------
Date: Tue, 15 Jun 2004 18:57:43 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Mail::POP3Client
Message-Id: <cangr7$anh$2@wisteria.csv.warwick.ac.uk>
Quoth A Ymous <a.ymous3@btinternet.com>:
> Is there a way of monitoring the progress of message retrieval when
> using Mail::POP3Client? I had a large message to retrieve (>5MB) and
> couldn't tell if the message was being retrieved or not.
Use RetriveToFile, passing a tied filehandle which saves the data to a
variable instead of a file but gives progress reports as well.
Ben
--
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * ben@morrow.me.uk
------------------------------
Date: 15 Jun 2004 10:53:14 -0700
From: Petri <Petri_member@newsguy.com>
Subject: Re: OLE, WMI and ExecMethod - possible?
Message-Id: <cand2a0c6s@drn.newsguy.com>
In article <6e613a32.0406150656.678640fa@posting.google.com>, Daniel Berger
says...
> Is there a way to use ExecMethod() on a SWbemServices object via
> Win32::OLE?
> my $wmi = Win32::OLE->GetObject("winmgmts:\\");
What is the backslashing supposed to do there?
> my $rv = $wmi->ExecMethod("Win32_Service","StartService","ClipSrv")
> or die "Error", Win32::OLE->LastError;
> Relevant link:
>http://msdn.microsoft.com/library/default.asp?url=/library/enus/wmisdk/wmi/swbemservices.asp
Why do you even ask, when you are providing a direct link to the answer?
Just click on SWbemServices.ExecMethod and everything is explained to you, with
several examples in VBScript.
Had you cared to look, you would have seen that you are providing totally wrong
parameters to ExecMethod().
Here's a simple example that does what you want to do:
---8<---
#!/usr/bin/perl
use strict;
use warnings;
use Win32::OLE;
my $service = Win32::OLE->GetObject("winmgmts:Win32_Service='SETI'");
$service->StartService();
---8<---
If you absolutely must use ExecMethod, you will have to figure out how to
provide the object path parameter in Perl.
Petri
------------------------------
Date: 15 Jun 2004 11:07:53 -0700
From: AlexanderHeimann@yahoo.com (Alexander Heimann)
Subject: Re: parsing file name assigning extension to a variable
Message-Id: <1c63154d.0406151007.4e72c0e3@posting.google.com>
"gnari" <gnari@simnet.is> wrote in message news:<camck9$qv6$1@news.simnet.is>...
> "Alexander Heimann" <AlexanderHeimann@yahoo.com> wrote in message
> news:r8wzc.6636$US1.3423@fed1read02...
> > gnari wrote:
> > >
> > > you obviously are forgetting the directory part of the
> > > filename when opening it
> > >
> > gnari in the code below
> > I am using $file as the filename to open, if i comment out the open file
> > and read content portion i am able to parse the the file
> > is there a reason i can't use $file again
>
> [snip code where OP is forgetting the directory part]
>
> > opendir (DIR, "D:/D2") or die "couldn't open directory\n";
>
> here 'D:/D2' is the directory, you are reading. call this
> the 'directory part'
>
> > print " dir is $dir, name is $name, extension is $ext\n";
>
> here is your problem. your stupid debugging. why print
> a bunch of variables that have nothong to do with the problem?
> they are not used in the open
>
> > open($input, "<", "$file")
> > or die "Couldn't open file :!\n";
>
> always include the filename in the die()
> or die "Couldn't open file '$file' :!\n";
>
> if you had done this you would have seen no
> directory part ('D:/D2')
>
> gnari
Gnar,
I added a variable for the directory part. When i took the die() out
of the open file it worked ok, but when the die was in there it
didn't. For some reason the open file was reading two files with no
filenames in the directory. I don't see the files. i am not really
sure why that is happening. So the open file wouldn't work because
there was no name
Anyways it is working without the die and I think i will be able to
use this now and use the extension and the content of the file
variable in my SQL insert statement. The reason i am printing out
(stupid error checking) is to make sure the variables are holding the
correct values to later use in a SQL statement
use File::Basename;
fileparse_set_fstype("MSDOS");
$mydir = "D:/D2";
opendir (DIR, $mydir) || die "couldn't opendir $mydir: $!\n";
while ($file = readdir(DIR)) {
($name, $dir, $ext) = fileparse($file, '\..*');
$ext =~s/^\.//;
print "extension is $ext\n";
open($input, "<$mydir/$file "); #|| die "couldn't open $mydir/$file
for reading :!\n";
while(<$input>){
undef $/;
$content = <INPUT>;
print if /of/;
print $content;
}
close($input);
}
closedir (DIR);
------------------------------
Date: Tue, 15 Jun 2004 19:31:44 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: parsing file name assigning extension to a variable
Message-Id: <canini$v6d$1@news.simnet.is>
"Alexander Heimann" <AlexanderHeimann@yahoo.com> wrote in message
news:1c63154d.0406151007.4e72c0e3@posting.google.com...
[using readdir and open]
some of the entries returned by readdir may not be readable files,
for examples directories.
for example '.' and '..'
gnari
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 6694
***************************************