#!/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 () { $_ =~ 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) ; }