Thread Aufruf auf andere Datei umleiten (2 answers)
Opened by Hans Meiser at 2012-05-07 10:51

Linuxer
 2012-05-07 11:32
#158121 #158121
User since
2006-01-27
3870 Artikel
HausmeisterIn

user image
Mit CPAN:Getopt::Long kann man z.B. die Optionen verarbeiten und entsprechend reagieren.
Mit exec() lassen sich externe Programme aufrufen, wobei gleichzeitig das Skript beendet wird.

Schema (ungetestet):
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#! /usr/bin/perl
use strict;
use warnings;

use Getopt::Long;

### MAIN

my $call_external_program = 0;

GetOptions(
  'extern' => \$call_external_program,
) or exit 127;


if ( $call_external_program ) {
  # if option was set to execute external program, do that and terminate this script
  # provide rest of @ARGV to the external program
  exec( "external_program", @ARGV );
}

### else do some other stuff 
meine Beiträge: I.d.R. alle Angaben ohne Gewähr und auf Linux abgestimmt!
Die Sprache heisst Perl, nicht PERL. - Bitte Crossposts als solche kenntlich machen!

View full thread Aufruf auf andere Datei umleiten