[27039] in Perl-Users-Digest
Perl-Users Digest, Issue: 8951 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 14 11:05:54 2006
Date: Tue, 14 Feb 2006 08:05:05 -0800 (PST)
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, 14 Feb 2006 Volume: 10 Number: 8951
Today's topics:
Accessing query time via DBI / DBD::MySQL <usenet05@drabble.me.uk>
Re: Accessing query time via DBI / DBD::MySQL <emschwar@fc.hp.com>
Re: Best way for -h option for script to run perldoc on <a24061@yahoo.com>
Re: Best way for -h option for script to run perldoc on <1usa@llenroc.ude.invalid>
Re: Best way for -h option for script to run perldoc on <dlking@cpan.org>
Main Application Crashes during running a external proc <rbcs@gmx.net>
Re: Main Application Crashes during running a external <1usa@llenroc.ude.invalid>
Recursive Directory Traversal <anon@nospam.net>
Re: Recursive Directory Traversal <1usa@llenroc.ude.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 14 Feb 2006 13:55:26 GMT
From: Graham Drabble <usenet05@drabble.me.uk>
Subject: Accessing query time via DBI / DBD::MySQL
Message-Id: <Xns976A8DA478C98grahamdrabblelineone@ID-77355.user.dfncis.de>
When you run a query in MySQL the last row returned is of the form:
4 rows in set (0.20 sec)
How can I get access to that time when using DBI / DBD::MySQL ?
--
Graham Drabble
http://www.drabble.me.uk/
------------------------------
Date: 14 Feb 2006 08:32:08 -0700
From: Eric Schwartz <emschwar@fc.hp.com>
Subject: Re: Accessing query time via DBI / DBD::MySQL
Message-Id: <878xseard3.fsf@localhost.localdomain>
Graham Drabble <usenet05@drabble.me.uk> writes:
> When you run a query in MySQL the last row returned is of the form:
>
> 4 rows in set (0.20 sec)
That's not actually part of the rows that are returned; it's something
the client prints out.
> How can I get access to that time when using DBI / DBD::MySQL ?
perldoc -f time
-=ERic
------------------------------
Date: Tue, 14 Feb 2006 12:12:42 +0000
From: Adam Funk <a24061@yahoo.com>
Subject: Re: Best way for -h option for script to run perldoc on itself?
Message-Id: <q2u8c3-cum.ln1@news.ducksburg.com>
On 2006-02-10, Donald King <dlking@cpan.org> wrote:
(1)
>> exec("perldoc " . $0) if ( $option{h} );
> FWIW, if you do stick with exec-ing perldoc instead of Pod::Usage, you
> should probably use the list form of exec:
>
(2)
> exec("perldoc", $0) if $option{h};
>
> This works even if the user has renamed the script to a path containing
> shell meta characters (especially spaces).
Now that you mention it, I think I've read somewhere that (2) should
also be slightly more efficient because the command is executed and
the arguments are passed directly to it, without an intermediary
shell, whereas in (1) Perl executes a shell and passes the single
string to it to parse and process. Is this correct?
------------------------------
Date: Tue, 14 Feb 2006 12:30:34 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Best way for -h option for script to run perldoc on itself?
Message-Id: <Xns976A4C7C1A831asu1cornelledu@127.0.0.1>
Adam Funk <a24061@yahoo.com> wrote in
news:q2u8c3-cum.ln1@news.ducksburg.com:
> On 2006-02-10, Donald King <dlking@cpan.org> wrote:
>
> (1)
>>> exec("perldoc " . $0) if ( $option{h} );
>
>> FWIW, if you do stick with exec-ing perldoc instead of Pod::Usage,
>> you should probably use the list form of exec:
>>
> (2)
>> exec("perldoc", $0) if $option{h};
>>
>> This works even if the user has renamed the script to a path
>> containing shell meta characters (especially spaces).
>
> Now that you mention it, I think I've read somewhere that (2) should
> also be slightly more efficient because the command is executed and
> the arguments are passed directly to it, without an intermediary
> shell, whereas in (1) Perl executes a shell and passes the single
> string to it to parse and process. Is this correct?
perldoc -f exec
perldoc -f system
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Tue, 14 Feb 2006 09:21:11 -0600
From: Donald King <dlking@cpan.org>
Subject: Re: Best way for -h option for script to run perldoc on itself?
Message-Id: <RzmIf.160656$WH.74530@dukeread01>
Adam Funk wrote:
> On 2006-02-10, Donald King <dlking@cpan.org> wrote:
>
> (1)
>
>>>exec("perldoc " . $0) if ( $option{h} );
>
>
>>FWIW, if you do stick with exec-ing perldoc instead of Pod::Usage, you
>>should probably use the list form of exec:
>>
>
> (2)
>
>>exec("perldoc", $0) if $option{h};
>>
>>This works even if the user has renamed the script to a path containing
>>shell meta characters (especially spaces).
>
>
> Now that you mention it, I think I've read somewhere that (2) should
> also be slightly more efficient because the command is executed and
> the arguments are passed directly to it, without an intermediary
> shell, whereas in (1) Perl executes a shell and passes the single
> string to it to parse and process. Is this correct?
True, although the performance difference is unlikely to matter on a
modern system.
--
Donald King, a.k.a. Chronos Tachyon
http://chronos-tachyon.net/
------------------------------
Date: Tue, 14 Feb 2006 16:24:48 +0100
From: RBCS <rbcs@gmx.net>
Subject: Main Application Crashes during running a external process task
Message-Id: <pan.2006.02.14.15.24.47.762000@gmx.net>
Hallo zusammen
Hello I'v gota stupid questions
When I insert this scriptsnipe to my main Application, this part runs very
well but behind the main application crashes during this part is executing!
It crashes also even I take out the RunAsUser (AdminMisc) part!
Does someone has a idea?
use strict;
use warnings;
my $Domain = "Workgroup";
my $User = "testuser";
my $Password = "testiman";
my (@tasks);
my $taski=0;
#add some work!
$tasks[$taski] = ( "notepad" );
$taski++;
$tasks[$taski] = ( "msiexec" );
$taski++;
$tasks[$taski] = ( "notepad" );
#execute work
my $ResultofRunas = RunAs->User($Domain, $User, $Password, @tasks); print
"Result of Runas: $ResultofRunas"; #exit 0;
package RunAs;
use Win32::AdminMisc;
use POE qw(Wheel::Run Filter::Reference);
sub User{
my( undef, $Domain, $User, $Password, @Process ) = @_;
sub MAX_CONCURRENT_TASKS () { 3 }
my $Result = Win32::AdminMisc::LogonAsUser( $Domain,
$User,
$Password,
LOGON32_LOGON_INTERACTIVE );
if( $Result )
{
my $LogonUser = Win32::AdminMisc::GetLogonName(); print "Successfuly
started process as $LogonUser.\n"; $Result = POE::Session->create
( inline_states =>
{ _start => \&start_tasks,
next_task => \&start_tasks,
task_result => \&handle_task_result,
task_done => \&handle_task_done,
task_debug => \&handle_task_debug,
}
);
if( $Result )
{
print "Successful! The new processes PID is $Result.\n";
}
else
{
my $err= Error();
print"$err\n";
}
}
else
{
my $err = Error();
print"$err\n";
}
$poe_kernel->run();
my $logofresult = Win32::AdminMisc::LogoffAsUser(); print "Logging
off...\n";
sub Error
{
return( Win32::FormatMessage( Win32::AdminMisc::GetError() ) );
}
}
sub start_tasks {
my $heap = $_[HEAP];
while ( keys( %{ $heap->{task} } ) < MAX_CONCURRENT_TASKS ) {
my $next_task = shift @Process;
last unless defined $next_task;
print "Starting task for $next_task...\n"; my $task =
POE::Wheel::Run->new
( Program => ["$next_task", , ],
StdoutFilter => POE::Filter::Reference->new(), StdoutEvent =>
"task_result",
StderrEvent => "task_debug",
CloseEvent => "task_done",
);
$heap->{task}->{ $task->ID } = $task;
}
}
}
sub do_stuff {
binmode(STDOUT); # Required for this to work on MSWin32 my $task
= shift;
my $filter = POE::Filter::Reference->new(); my %result =
( task => $task,
status => "seems ok to me",
);
my $output = $filter->put( [ \%result ] ); print @$output;
}
}
sub handle_task_result {
my $result = $_[ARG0];
print "Result for $result->{task}: $result->{status}\n";
}
}
sub handle_task_debug {
my $result = $_[ARG0];
print "Debug: $result\n";
}
}
sub handle_task_done {
my ( $kernel, $heap, $task_id ) = @_[ KERNEL, HEAP, ARG0 ]; delete
$heap->{task}->{$task_id};
$kernel->yield("next_task");
}
}
------------------------------
Date: Tue, 14 Feb 2006 15:38:14 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Main Application Crashes during running a external process task
Message-Id: <Xns976A6C4C84A33asu1cornelledu@127.0.0.1>
RBCS <rbcs@gmx.net> wrote in
news:pan.2006.02.14.15.24.47.762000@gmx.net:
> When I insert this scriptsnipe to my main Application, this part runs
> very well but behind the main application crashes during this part is
> executing!
>
> It crashes also even I take out the RunAsUser (AdminMisc) part!
I would have tried to isolate what is related to the crash first. For
example, do you get the same behavior without POE? (This is the easy way
out for me, because I do not have POE installed, and I know nothing
about it).
>
> Does someone has a idea?
>
>
> use strict;
> use warnings;
>
> my $Domain = "Workgroup";
> my $User = "testuser";
> my $Password = "testiman";
> my (@tasks);
> my $taski=0;
>
> #add some work!
> $tasks[$taski] = ( "notepad" );
> $taski++;
> $tasks[$taski] = ( "msiexec" );
> $taski++;
> $tasks[$taski] = ( "notepad" );
You can replace all of the above with:
my @tasks = qw( notepad msiexec notepad );
> #execute work
> my $ResultofRunas = RunAs->User($Domain, $User, $Password, @tasks);
> print "Result of Runas: $ResultofRunas"; #exit 0;
Your style of shoving multiple statements per line is simply awful to
read as well as the fact that you use inconsistent indenting with
multiple closing braces at the same indent level. These factors make it
unnecessarily hard to read your code.
> sub User{
> my( undef, $Domain, $User, $Password, @Process ) = @_;
If you do not want to call the subs in RunAs as methods, then don't call
them as methods (i.e. use RunAs::User).
>
> sub MAX_CONCURRENT_TASKS () { 3 }
What is the point of this nested sub definition?
Anyway, after installing POE, I get the following results:
D:\Home\asu1\UseNet\clpmisc> perl -c synchk.pl
Global symbol "@Process" requires explicit package name at synchk.pl
line 74.
Unmatched right curly bracket at synchk.pl line 87, at end of line
syntax error at synchk.pl line 87, near "}"
synchk.pl had compilation errors.
Please post a short but complete script that compiles and runs with no
warnings/errors.
Please read the posting guidelines for this group.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Tue, 14 Feb 2006 10:50:01 -0500
From: "Sam" <anon@nospam.net>
Subject: Recursive Directory Traversal
Message-Id: <dssu79$m24$2@newslocal.mitre.org>
I'm trying to search a directory tree for a specific file, when that file is
found I need the path returned.
Does anyone know how to do this?
I have been trying to use File::Find. It traverses the directory tree well
enough, but it does not return anything.
In this specific example, I can assume that the file name I'm looking for
only occurs once.
Does anyone know how to do this? It seems as though this should be a
straightforward problem.
Thanks
------------------------------
Date: Tue, 14 Feb 2006 15:58:52 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Recursive Directory Traversal
Message-Id: <Xns976A6FCD0454Fasu1cornelledu@127.0.0.1>
"Sam" <anon@nospam.net> wrote in news:dssu79$m24$2@newslocal.mitre.org:
> I'm trying to search a directory tree for a specific file, when that
> file is found I need the path returned.
>
> Does anyone know how to do this?
> I have been trying to use File::Find. It traverses the directory tree
> well enough, but it does not return anything.
Please post a short but complete script so we can help you figure out
what you did wrong, and how to achieve the desired result.
> In this specific example, I can assume that the file name I'm looking
> for only occurs once.
>
> Does anyone know how to do this? It seems as though this should be a
> straightforward problem.
use File::Finder;
my ($file) = File::Finder->in('/path/filename.ext');
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
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 8951
***************************************