Main script crash
am 14.02.2006 00:50:43 von RBCS
Hallo zusammen
Habe noch ne blöde frage
Schaut euch das folgende script an. Das läuft hervorragend wenn ich es
alleine aufrufe. wenn ich dieses aber in meinem hauptscript einfüge
stürzt dieses nach ca 10sec ab...
Auch wenn ich die RunAsUser (AdminMisc) herausnehme stürzt dieses ab!
Hat da jemand ne idee warum?
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");
}
}
Re: Main script crash
am 14.02.2006 21:23:00 von Matthias Peick
RBCS skribis:
> Habe noch ne blöde frage
Ich auch: Kosteten die Buchstaben auf der Geburtsurkunde einzeln?
> Schaut euch das folgende script an. Das läuft hervorragend wenn ich es
> alleine aufrufe. wenn ich dieses aber in meinem hauptscript einfüge
> stürzt dieses nach ca 10sec ab...
Eine Fehlermeldung wäre hilfreich.
Re: Main script crash
am 15.02.2006 22:42:25 von RBCS
Hallo,
Leider gibt es keine fehlermeldung. Nur die nichtsnützige Crash melding
von Windows!
Mit der Debug funktion von komodo habe ich folgendes erhalten:
D:/Perl/lib/auto/POSIX/load_imports.al did not return a true value at D:/Perl/lib/POSIX.pm line 15
BEGIN failed--compilation aborted at D:/Perl/site/lib/POE/Kernel.pm line 11.
Compilation failed in require at (eval 8)[D:/Perl/site/lib/POE.pm:47] line 1.
BEGIN failed--compilation aborted at (eval 8)[D:/Perl/site/lib/POE.pm:47] line 1.
"sysconf" is not exported by the POSIX module
"setsid" is not exported by the POSIX module
"_SC_OPEN_MAX" is not exported by the POSIX module
"ECHO" is not exported by the POSIX module
"ICANON" is not exported by the POSIX module
"IEXTEN" is not exported by the POSIX module
"ISIG" is not exported by the POSIX module
"BRKINT" is not exported by the POSIX module
"ICRNL" is not exported by the POSIX module
"INPCK" is not exported by the POSIX module
"ISTRIP" is not exported by the POSIX module
"IXON" is not exported by the POSIX module
"CSIZE" is not exported by the POSIX module
"PARENB" is not exported by the POSIX module
"OPOST" is not exported by the POSIX module
"TCSANOW" is not exported by the POSIX module
Can't continue after import errors at D:/Perl/lib/POSIX.pm line 19
BEGIN failed--compilation aborted at D:/Perl/site/lib/POE/Wheel/Run.pm line 14.
Compilation failed in require at (eval 15)[D:/Perl/site/lib/POE.pm:59] line 1.
BEGIN failed--compilation aborted at (eval 15)[D:/Perl/site/lib/POE.pm:59] line 1.
could not import qw(Kernel Wheel::Run) at D:\PerlData\poe2.pl line 25
BEGIN failed--compilation aborted at D:\PerlData\poe2.pl line 25.
aber alles nicht von meinem Script!
Roman
On Tue, 14 Feb 2006 21:23:00 +0100, Matthias Peick wrote:
> RBCS skribis:
>
>> Habe noch ne blöde frage
>
> Ich auch: Kosteten die Buchstaben auf der Geburtsurkunde einzeln?
>
>> Schaut euch das folgende script an. Das läuft hervorragend wenn ich es
>> alleine aufrufe. wenn ich dieses aber in meinem hauptscript einfüge
>> stürzt dieses nach ca 10sec ab...
>
> Eine Fehlermeldung wäre hilfreich.
Re: Main script crash
am 16.02.2006 08:59:40 von Christian Winter
RBCS schrieb:
> Hallo,
>
> Leider gibt es keine fehlermeldung. Nur die nichtsnützige Crash melding
> von Windows!
[...snipped...]
Zeile 25 ist also vermutlich
use POE qw(Wheel::Run Filter::Reference);
bei genau dieser Anweisung steigt Perl auch bei mir (WinXP, AS 5.8.7)
aus, allerdings mit einer etwas aussagekräftigeren Meldung:
[quote]
MSWin32 does not fully support fork+exec
BEGIN failed--compilation aborted at C:/Perl/site/lib/POE/Wheel/Run.pm
line 64.
Compilation failed in require at (eval 83) line 1.
BEGIN failed--compilation aborted at (eval 83) line 1.
could not import qw(Wheel::Run) at -e line 1
BEGIN failed--compilation aborted at -e line 1.
[/quote]
Welche Perl Version/Distribution verwendest Du?
Aus "perldoc POE::Wheel::Run":
[quote]
ActiveState Perl doesn't like this module one bit.
[/quote]
Kann das das Problem sein?
-Christian
Re: Main script crash
am 22.02.2006 15:29:00 von RBCS
Hallo,
Habe die folgende Version
ActiveState 5.8.7 built for MSWin32-X86-multi-thread
Binary build 815 [211909]
built on 2 Nov 2005
Roman
On Thu, 16 Feb 2006 08:59:40 +0100, Christian Winter wrote:
> RBCS schrieb:
>> Hallo,
>>
>> Leider gibt es keine fehlermeldung. Nur die nichtsnützige Crash melding
>> von Windows!
> [...snipped...]
>
> Zeile 25 ist also vermutlich
> use POE qw(Wheel::Run Filter::Reference);
>
> bei genau dieser Anweisung steigt Perl auch bei mir (WinXP, AS 5.8.7) aus,
> allerdings mit einer etwas aussagekräftigeren Meldung:
>
> [quote]
> MSWin32 does not fully support fork+exec BEGIN failed--compilation aborted
> at C:/Perl/site/lib/POE/Wheel/Run.pm line 64.
> Compilation failed in require at (eval 83) line 1. BEGIN
> failed--compilation aborted at (eval 83) line 1. could not import
> qw(Wheel::Run) at -e line 1 BEGIN failed--compilation aborted at -e line
> 1. [/quote]
>
> Welche Perl Version/Distribution verwendest Du?
>
> Aus "perldoc POE::Wheel::Run":
> [quote]
> ActiveState Perl doesn't like this module one bit. [/quote]
>
> Kann das das Problem sein?
>
> -Christian
Re: Main script crash
am 22.02.2006 16:21:01 von Christian Winter
RBCS schrieb:
> Hallo,
>
> Habe die folgende Version
>
> ActiveState 5.8.7 built for MSWin32-X86-multi-thread
> Binary build 815 [211909]
Das wird dann das Problem sein. Also entweder auf POE::Wheel::Run
verzichten, auf eine neue ActiveState-Version hoffen oder das Package
selbst debuggen, vermutlich wird die Möglichkeit 1 am leichtesten zu
verdauen sein.
Wie die Fehlermeldung die Du gepostet hast sagt, wird die Funktion
"sysconf" von POSIX.pm nicht exportiert (wie auch einiges andere).
eventuell könnte cygwin eine Möglichkeit sein, wobei mein cygwin-Perl
hier sysconf ebenfalls nicht mag.
-Christian