Connect failed: Connection timed out

[GastForen Betriebsysteme und Dienste HELIOS Löscheneintrag im Skript

  • Suche
  • Hilfe
  • Lesezeichen
  • Benutzerliste
Themen
Beiträge
Moderatoren
Letzter Beitrag

Löscheneintrag im Skript

Pippalu
Beiträge gesamt: 279

1. Jun 2016, 10:01
Beitrag # 1 von 8
Bewertung:
(8566 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Hallo zusammen,

ich habe im Anhang ein Skript die mir Vektor in PNG wandelt.
Klappr super.
Irgendwie weiss ich aber gerade nicht wo ich da
die Anweisung reingebe, das er mit das Original.eps löscht.
Kann mir da jemand helfen?

#!var/run/runperl -w
# $Id: eps2png.pl,v 1 2016/01/25 dhe 14:12:03 tom Exp $

#
# Sample configuration
#
my $default_settings = <<'</SETTINGS>'; # Let Perl ignore the settings block
<SETTINGS>
<General
Enable="true"
Hot_Folder="/demovol/eps2jpeg"
Include_Subdirectories="false"
User=""
Timeout=""
/>
<File_Types
Types="EPSF"
Suffixes="eps"
Folder_Changes="false"
/>
<Environment
OUTDIR="DONE"
MAXWIDTH="500"
MAXHEIGHT="500"
/>
</SETTINGS>

use strict;
BEGIN {
use vars qw($HELIOSDIR);
$HELIOSDIR = $ENV{"HELIOSDIR"} or die "HELIOSDIR not set in environment\n";
unshift(@INC, "$HELIOSDIR/etc/perl");
}
use HELIOS::Utils;
use File::Basename;
use IO::Handle;
STDERR->autoflush(1); # Write data immediately to fd

my $scriptdebug = int ($ENV{SCRIPTDEBUG} || "0");
my $maxwidth = int ($ENV{MAXWIDTH} || "500");
my $maxheight = int ($ENV{MAXHEIGHT} || "500");
my $outdir = $ENV{OUTDIR} || die "$0: directory not defined\n";
my $file = $ARGV[0] || die "$0: no input file specified\n";

print "Start Script: $0 $file\n" if ($scriptdebug > 0);

my $dir = (dirname $file)."/";
my $filename = basename $file;
(my $newbase = $filename) =~ s/\.\w*$//;

# create output directory and move the file into it
system("$HELIOSDIR/bin/dt", "mkdir", "$dir$outdir") if not stat("$dir$outdir");
system("$HELIOSDIR/bin/dt", "mv", "$file", "$dir$outdir");

# go to output directory
my $workdir = HELIOSPathToSystemPath("$dir$outdir");
chdir($workdir);

my $x = 0;
my $y = 0;
my $xshift = 0;
my $yshift = 0;
my $res = 72;
my $GotBox = 0;

# get the BoundingBox from the EPSF
open(FD, "<$filename");
while(<FD>) {
my $line = $_;

# try to get the HiResBoundingBox...
if($line =~ /%%HiResBoundingBox: (\d+.\d+) (\d+.\d+) (\d+.\d+) (\d+.\d+)/) {
print "HiResBoundingBox: llx: $1\tlly: $2\turx: $3\tury: $4\n" if ($scriptdebug > 0);
$xshift = $1/72; # the shift value unit is inch not pixel
$yshift = $2/72;
$x = $3-$1;
$y = $4-$2;
last;
}
# ... but use the BoundingBox when it it not available.
next if $GotBox;
if ($line =~ /%%BoundingBox: (\d+) (\d+) (\d+) (\d+)/) {
print "BoundingBox: llx: $1\tlly: $2\turx: $3\tury: $4\n" if ($scriptdebug > 0);
$xshift = $1/72; # the shift value unit is inch not pixel
$yshift = $2/72;
$x = $3-$1;
$y = $4-$2;
$GotBox = 1;
}
}
close(FD);

if($x eq 0 || $y eq 0) { die "Sorry, no suitable bounding box found\n"; }
print "Image size: x: $x\ty: $y\txshift: $xshift\tyshift: $yshift\n" if ($scriptdebug > 0);

# calculate a new resolution to get an image with specified dimensions
# check x and y pixels and calculate new x and y
if($x > $maxwidth) { # if x is more than specified max value
my $scale = $maxwidth/$x; # factor ($scaling times higher than $maxwidth)
$res *= $scale; # the new resolution
$x *= $scale; # recalculate $x and $y
$y *= $scale;
print "x is greater than $maxwidth px - new x: $x; new y: $y; new resolution: $res (scaling=$scale)\n" if ($scriptdebug > 0);
}
if($y > $maxheight) { # same as above, but using y now
my $scale = $maxheight/$y;
$res *= $scale;
$x *= $scale;
$y *= $scale;
print "y is greater than $maxheight px - new x: $x; new y: $y; new resolution: $res (scaling=$scale)\n" if ($scriptdebug > 0);
}

$xshift = -$xshift;

# run 'psrip' zum erzeugen eines Temporaeren TIff ...
print STDERR "Status: Running 'psrip' for file $file\n";
my @cmd = ("$HELIOSDIR/bin/psrip");
push @cmd, "-A";
push @cmd, "-T";
push @cmd, "-l 3";
push @cmd, "-s $xshift,$yshift";
push @cmd, "-e $x,$y";
push @cmd, "-oPrintResolution=$res";
push @cmd, "-oRasterImageType=TIFF";
push @cmd, "-oTransparencyMask=on";
push @cmd, ("-i", "$filename", "$newbase");
print "Cmd: ".(join " ",@cmd)."\n" if ($scriptdebug > 0);
system(@cmd);

# ... Konvertierung zum PNG Freigestellt
print STDERR "Status: Running 'layout' for file $newbase.1.tif\n";
@cmd = ("$HELIOSDIR/bin/layout");
push @cmd, "-v" if ($scriptdebug > 0);
push @cmd, "-oOmitProfile=True";
push @cmd, "-oSpotToProcess=True";
push @cmd, "-oPrintColor=RGB";
push @cmd, "-oyPix=200";
push @cmd, "-oxPix=200";
push @cmd, "-oPrintResolution=72";
push @cmd, ("-l", "$newbase.1.tif", "{unix,native,,PNGf}$newbase.png");
print "Cmd: ".(join " ",@cmd)."\n" if ($scriptdebug > 0);
system(@cmd);

# delete the temporary TIFF file
system("$HELIOSDIR/bin/dt", "rm", "$newbase.1.tif");


print "End Script: $0 $file\n" if ($scriptdebug > 0);
X

Löscheneintrag im Skript

Bernd Flachsbart
Beiträge gesamt: 48

1. Jun 2016, 12:55
Beitrag # 2 von 8
Beitrag ID: #550051
Bewertung:
(8519 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Hallo Pippalu,

man müsste ganz unten vor der Zeile

Code
print "End Script:   $0 $file\n" if ($scriptdebug > 0); 



noch einfügen:

Code
system("$HELIOSDIR/bin/dt", "rm", "$file"); 



Hinweis: Vom Code her müsste es passen, ich habe es aber nicht getestet, also ohne Gewähr.

Gruß
Bernd Flachsbart


als Antwort auf: [#550048]

Löscheneintrag im Skript

Bernd Flachsbart
Beiträge gesamt: 48

1. Jun 2016, 13:03
Beitrag # 3 von 8
Beitrag ID: #550053
Bewertung:
(8517 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Hallo noch mal,

Sorry, da war ich zu schnell...

Korrektur, es muss lauten:

Code
system("$HELIOSDIR/bin/dt", "rm", "$filename"); 


Die Eingabedatei wurde ja bereits verschoben, daher steht sie unter dem vollständigen Pfad in $file nicht mehr zur Verfügung.

Bernd


als Antwort auf: [#550048]

Löscheneintrag im Skript

GreatOm
Beiträge gesamt: 378

2. Jun 2016, 10:14
Beitrag # 4 von 8
Beitrag ID: #550082
Bewertung:
(8381 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Moin!

Unter
Code
# delete the temporary TIFF file 
system("$heliosdir/bin/dt", "rm", "$newbase.1.tif");

sollte
Code
# delete the original file 
system("$heliosdir/bin/dt", "rm", "$basename");


helfen (nicht getestet, also Vorsicht!).

Allerdings ist dieses Script eigentlich veraltet, da psrip seit einigen Jahren schon die BoundingBox eines EPS auswertet.
Wenn also ein EPS gerendert wird, ergibt sich die "Seitengröße" automatisch, so dass nicht mehr "Perl-Voodoo" gemacht werden muss um die Zielgröße zu setzen. Damit würde das Skript erheblich einfacher.

PS. Ich habe mal etwas gestöbert und unter http://www.helios.de/...rowser.html?id=u0727 folgendes gefunden:
Zitat - The page size is now set from the %%BoundingBox or %%HiResBoundingBox comment if no explicit page size is set. This is useful e.g. when rendering EPS files with psrip.


PPS. Falls PDF HandShake vorhanden ist, wäre es evtl. sinnvoller Vektor-EPS zu PDF zu wandeln. Das könnte auch einfach über einen HotFolder laufen (Drucken auf Create PDF Server Queue) und hätte den Vorteil, dass die Vektordaten in bester Qualität erhalten bleiben.

Gruß,

GreatOm


als Antwort auf: [#550048]

Löscheneintrag im Skript

Bernd Flachsbart
Beiträge gesamt: 48

2. Jun 2016, 13:28
Beitrag # 5 von 8
Beitrag ID: #550109
Bewertung:
(8354 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Hallo GreatOm,

Antwort auf [ GreatOm ]
Code
system("$heliosdir/bin/dt", "rm", "$basename"); 



So wie ich es sehe ist gar keine Skalar Variable $basename definiert!
Ich denke, dass mein zweiter Vorschlag mit $filename korrekt war.

Gruß
Bernd Flachsbart


als Antwort auf: [#550082]

Löscheneintrag im Skript

GreatOm
Beiträge gesamt: 378

2. Jun 2016, 15:16
Beitrag # 6 von 8
Beitrag ID: #550119
Bewertung:
(8329 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Antwort auf [ Bernd Flachsbart ] So wie ich es sehe ist gar keine Skalar Variable $basename definiert!
Ich denke, dass mein zweiter Vorschlag mit $filename korrekt war.


und ich sach noch "Vorsicht ungetestet" ;-)

Stimmt wohl "$filename" ist hier vermutlich besser. Aber wir werde ja bestimmt feedback bekommen wie es denn nun funktioniert.

Gruß,

GreatOm


als Antwort auf: [#550109]

Löscheneintrag im Skript

Pippalu
Beiträge gesamt: 279

9. Jun 2016, 14:41
Beitrag # 7 von 8
Beitrag ID: #550289
Bewertung:
(8122 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Hallo zusammen, sorry ich kann erst jetzt schreiben.
Ich werde es dann mit dem Filename testen. Gebe dann Feedback!

Danke schon einmal!


als Antwort auf: [#550119]

Löscheneintrag im Skript

Pippalu
Beiträge gesamt: 279

9. Jun 2016, 14:49
Beitrag # 8 von 8
Beitrag ID: #550290
Bewertung:
(8122 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
so hat super geklappt und es schaut8 am ende so aus:

# delete the temporary TIFF file
system("$HELIOSDIR/bin/dt", "rm", "$newbase.1.tif");

# delete the original file
system("$HELIOSDIR/bin/dt", "rm", "$filename");


print "End Script: $0 $file\n" if ($scriptdebug > 0);


Danke euch!


als Antwort auf: [#550289]
X