Running perl script from GenericAgent CMD

Moderator: crythias

Locked
marcovip
Znuny newbie
Posts: 1
Joined: 19 Sep 2013, 20:43
Znuny Version: 3.2.9

Running perl script from GenericAgent CMD

Post by marcovip »

Hello All.

I need to write a txt file on my web server every time a Ticket is locked.
I'm trying to do this using GenericAgent feature adding the following link on CMD field in "Ticket Command":

Code: Select all

/usr/bin/perl /opt/otrs/bin/myscript.pl
as the result, Is expected a result.txt file on the same script path.

I can see the following OTRS logs:

Code: Select all

Thu Feb 5 09:54:46 2015	notice	OTRS-CGI-40	Command returned a nonzero return code: rc=256, err=
Thu Feb 5 09:54:46 2015	notice	OTRS-CGI-40	Execute '/usr/bin/perl /opt/otrs/bin/myscript.pl' for Ticket (XXXXXXXXXXXX/XXX).
Thu Feb 5 09:54:46 2015	notice	OTRS-CGI-40	Run GenericAgent Job '1' from db.
Thu Feb 5 09:54:37 2015	notice	OTRS-CGI-40	New GenericAgent job '1' added (UserID=2).
And... no file result.txt!

this is the content of myscript.pl:

Code: Select all

use strict;
use warnings;
use POSIX qw/strftime/;

open(my $fh, '>', 'result.txt');
print $fh "File written by Perl\n ";
print $fh strftime('%Y-%m-%d',localtime);
print $fh "\n ";

print $fh strftime ('%a %b %e %H:%M:%S %Y', gmtime);
close $fh;
The point are;
- I have no file created after running the GenericAgent
- really sure I am missing something but I can't figure out what...

Any directions?
I'm using OTRS 3.3.3 on CentOS

Thanks in advance
kostasps
Znuny newbie
Posts: 1
Joined: 20 Feb 2015, 10:07
Znuny Version: 3.2.10
Real Name: Kostas Psilopoulos
Company: ISNetwork

Re: Running perl script from GenericAgent CMD

Post by kostasps »

Hello to all!

I do have the exact same problem as the above mentioned (Command returned a nonzero return code: rc=256, err=).

I use a bash script to append the ticket number to a file.
The version i'm testing this on is 3.3.11 to which i'm planning to upgrade. I also use the ITSM packets.

My script and my output file are in otrs home folder and the same user and group as all the other files and 777 permissions (just testing for now...)

Code: Select all

-rwxrwxrwx  1 otrs www-data     46 Feb 20 14:49 test
-rwxrwxrwx  1 otrs www-data     60 Feb 20 14:48 test.sh
i call the script using

Code: Select all

/bin/bash /opt/otrs/test.sh ARG[0]
in generic agent interface

and the script is just

Code: Select all

#!/bin/bash

TICKET_NUMBER=$1
echo "$TICKET_NUMBER" >> test
Is anybody able to figure this out so i could go on with my script?

Thank you very much
Kostas
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Running perl script from GenericAgent CMD

Post by crythias »

Then

Code: Select all

return 0;
For examples, look at otrs/bin/*.pl and observe return codes.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Locked