1
2
3
4
5
6
7
8
9
10
#!/usr/bin/perl
#Saci Script als Basis genommen
# dieses Script liest Zeile für Zeile aus einer CSV und erstellt auf der Basis dieser Zeilen Tickets im Ticketsystem
use strict;
use LWP;
use SOAP::Lite('autodispatch', proxy => "https://xxx:50002/otrs/rpc.pl");
my $rpc_connect = Core->new() ;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/perl
#Saci Script als Basis genommen
# dieses Script liest Zeile für Zeile aus einer CSV und erstellt auf der Basis dieser Zeilen Tickets im Ticketsystem
use strict;
use LWP;
use SOAP::Lite('autodispatch', proxy => "https://sxxxx.xxx.de:50002/otrs/rpc.pl");
my $rpc_connect = Core->new() ;
my $csv_file = shift @ARGV;
my $soap_user = 'xx' ;
my $soap_password = 'xx' ;
my $lock = 'unlock';
my $priority = 3;
my $open_state = 'open';
my $open_owner = 1;
my $responsible = 'xx.xx@xx.de';
my $mail_from = 'xx.xx@xx.de';
my $open_user = 1;
my $open_type = 'ServiceRequest';
die "Keine CSV Datei angegeben" unless $csv_file;
my $open_subject = 'WIRD AUS CSV geholt';
my $open_queue = 'WIRD AUS CSV geholt';
my $body = 'Wird aus CSV geholt';
my $mail_to = 'WIRD AUS CSV GEHOLT';
my $mail_customer = 'wird aus CSV geholt';
open(DATAFILE, "< $csv_file") or die "Kann $csv_file nicht finden";
my $zaehler = 0;
while (<DATAFILE>)
{
$_ =~ s/"//g;
$_ =~ s/\r\n//g;
$zaehler++;
next if $zaehler eq 1; #Ueberschrift filtern
($open_subject, $body, $open_queue, $open_type, $priority, $open_state, $mail_to ) = split (";", $_);
$mail_customer = $mail_to;
print "\n Run: $zaehler Action: Open Ticket for $mail_to in Queue: $open_queue mit Title $open_subject \n";
open_ticket( ) ;
}
close(DATAFILE);
# if ( $trigger_subject eq $close_subject ) {
# my @ticket_ids = search_ticket($hostname, $trigger_name) ;
# if (@ticket_ids) {
# close_ticket(@ticket_ids) }
# }
#-- Functions
sub open_ticket {
my $ticket_number = $rpc_connect->Dispatch( $soap_user, $soap_password, 'TicketObject','TicketCreateNumber');
#print "User-Data: $soap_user, $soap_password\n";
print "-----Ticket created: $ticket_number \n";
my %ticket_data = (
TN => $ticket_number,
Title => $open_subject,
Queue => $open_queue,
Lock => $lock,
Priority => $priority,
State => $open_state,
Customer => $mail_customer,
CustomerUser => $mail_customer,
OwnerID => $open_owner,
UserID => $open_owner,
Responsible => $responsible,
Type => $open_type,
) ;
my $ticket_id = $rpc_connect->Dispatch( $soap_user, $soap_password, 'TicketObject', 'TicketCreate', %ticket_data ) ;
print "-----Ticket id: $ticket_id \n";
my %article_data = (
TicketID => $ticket_id,
ArticleType => 'email-external',
SenderType => 'agent',
From => $mail_from,
To => $mail_to,
CC => '',
ReplyTo => $mail_from,
MessageID => '',
Subject => $open_subject,
Body => $body,
Charset => 'UTF-8',
MimeType => 'text/html',
HistoryType => 'NewTicket',
HistoryComment => 'Ticket by RPC',
UserID => 1,
NoAgentNotify => 0,
AutoResponseType => 'auto reply',
Loop => 0,
);
$rpc_connect->Dispatch( $soap_user, $soap_password, 'TicketObject', 'ArticleSend', %article_data) ;
}
Guest soapverzweifelterIO::Socket::SSL version 1.984 required--this is only version 1.38 at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
Guest soapverzweifelter$VERSION = "5.816"; auf allen Systemen.