Leser: 20
1 2 3
if (substr (`attrib $pfad_datei`,0,1) eq 'A') { print "Datei hat das Archiv-Attribut\n"; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#! /usr/bin/perl use strict; use warnings; use Win32::File qw( ARCHIVE HIDDEN ); my $attrib; if ( Win32::File::GetAttributes( $0, $attrib ) ) { print "$0 has to be archived.\n" if $attrib & ARCHIVE; print "$0 is hidden.\n" if $attrib & HIDDEN; } else { print "Could not get attributes for $0.\n"; }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
D:\temp>attrib archive.pl
A H D:\temp\archive.pl
D:\temp>perl archive.pl
archive.pl has to be archived.
archive.pl is hidden.
D:\temp>attrib -a archive.pl
Versteckte Datei wird nicht zurückgesetzt - D:\temp\archive.pl
D:\temp>perl archive.pl
archive.pl has to be archived.
archive.pl is hidden.
D:\temp>attrib -ha archive.pl
Unzulässige Option - -ha
D:\temp>attrib -h -a archive.pl
D:\temp>perl archive.pl
D:\temp>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#!/usr/bin/perl -w use strict; use warnings; my $errorbindings; BEGIN { eval "use Win32::File qw/ ARCHIVE /"; if ($@) { $errorbindings = $@; } } if (!$errorbindings) { Win32::File::GetAttributes('$0', my $attributes); if ( $attributes | ARCHIVE() ) { print "Attribut fuer $0 ist gesetzt\n"; } } else { print "Schrott: >$errorbindings<\n" }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#!/usr/bin/perl -w use strict; use warnings; my $errorbindings; BEGIN { eval "use Win32::File qw/ :DEFAULT /"; if ($@) { $errorbindings = $@; } } if (!$errorbindings) { if (Win32::File::GetAttributes("$0", my $attributes)) { if ( $attributes & SYSTEM ) { print "Attribut S fuer $0 ist gesetzt\n"; } } } else { print "Schrott: >$errorbindings<\n" }
`attrib \"$datei\"`