Call a GenericAgent-Job from within another Perl-Script

Hello, I want to call a GenericAgent-Job from within another Perl-Script. I want do do some work in the otrs database (Oracle) and then call that Agent-Job subsequently. Like it is done for manual job invocation using URL "http://localhost/otrs/index.pl?Action=AdminGenericAgent&Subaction=RunNow&Pro..." but called from commandline (Cron). Since I'm a very novize regarding Perl I would be grateful if someone could point me in the right direction. Maybe this problem has already been solved. Snip***** use Kernel::Modules::AdminGenericAgent; (presupposed I'm in /opt/otrs) %ParamList = ("Subaction" => "RunNow", "Profile" => "Test"); Kernel::Modules::AdminGenericAgent::Run(%ParamList); Snap***** I saw there is a constructor which needs to be called at first, but no idea how to do this correctly. And here an extract of AdminGenericAgent.pm Snip***** sub new { my $Type = shift; my %Param = @_; # allocate new hash for object my $Self = {}; bless ($Self, $Type); foreach (keys %Param) { $Self->{$_} = $Param{$_}; } # check needed Opjects foreach (qw(ParamObject DBObject TicketObject LayoutObject LogObject ConfigObject)) { if (!$Self->{$_}) { $Self->{LayoutObject}->FatalError(Message => "Got no $_!"); } } $Self->{PriorityObject} = Kernel::System::Priority->new(%Param); $Self->{StateObject} = Kernel::System::State->new(%Param); $Self->{LockObject} = Kernel::System::Lock->new(%Param); $Self->{GenericAgentObject} = Kernel::System::GenericAgent->new(%Param); return $Self; } # -- sub Run { my $Self = shift; my %Param = @_; my $Output; # get confid data $Self->{StartHit} = $Self->{ParamObject}->GetParam(Param => 'StartHit') || 1; $Self->{SearchLimit} = $Self->{ConfigObject}->Get('SearchLimit') || 500; $Self->{SortBy} = $Self->{ParamObject}->GetParam(Param => 'SortBy') || 'Age'; $Self->{Order} = $Self->{ParamObject}->GetParam(Param => 'Order') || 'Down'; $Self->{Profile} = $Self->{ParamObject}->GetParam(Param => 'Profile') || ''; $Self->{SaveProfile} = 1; $Self->{TakeLastSearch} = $Self->{ParamObject}->GetParam(Param => 'TakeLastSearch') || ''; $Self->{SelectTemplate} = $Self->{ParamObject}->GetParam(Param => 'SelectTemplate') || ''; $Self->{EraseTemplate} = $Self->{ParamObject}->GetParam(Param => 'EraseTemplate') || ''; # get db job data my %DBParam = $Self->{GenericAgentObject}->JobGet(Name => $Self->{Profile}) if ($Self->{Profile}); # run job now if ($Self->{Subaction} eq 'RunNow' && %DBParam) { $Self->{GenericAgentObject}->JobRun( Job => $Self->{Profile}, UserID => 1, ); # redirect return $Self->{LayoutObject}->Redirect( OP => "Action=$Self->{Action}", ); } # create new job if ($Self->{Subaction} eq 'Add' && $Self->{Profile}) { # insert new profile params $Self->{GenericAgentObject}->JobAdd( Name => $Self->{Profile}, Data => { ScheduleLastRun => '', }, ); # redirect return $Self->{LayoutObject}->Redirect( OP => "Action=$Self->{Action}&Subaction=LoadProfile&Profile=$Self->{Profile}", ); } Snap***** Thanks a lot. Greetings Marco

Hello, On Di, Feb 06, 2007 at 06:44:59 +0100, Marco Friebe wrote:
I want to call a GenericAgent-Job from within another Perl-Script.
I want do do some work in the otrs database (Oracle) and then call that Agent-Job subsequently.
Like it is done for manual job invocation using URL "http://localhost/otrs/index.pl?Action=AdminGenericAgent&Subaction=RunNow&Pro..." but called from commandline (Cron).
It is possible to insert GenericAgent jobs into a file. Per default the file is Kernel/Config/GeneriCAgent.pm If a job is defined there, just call ./bin/GenericAgent.pl and the jobs stored in the GenericAgent.pm file will be executed. Kind regards, Christian -- ((otrs)) :: OTRS GmbH :: Europaring 4 :: D - 94315 Straubing Fon: +49 (0) 9421 56818-0 :: Fax: +49 (0) 9421 56818-18 http://www.otrs.com/ :: Communication with success!
participants (2)
-
Christian Schoepplein
-
Marco Friebe