-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathprogram-argument-printer.pl
More file actions
executable file
·91 lines (60 loc) · 2.14 KB
/
Copy pathprogram-argument-printer.pl
File metadata and controls
executable file
·91 lines (60 loc) · 2.14 KB
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
#!/usr/bin/perl
# This script is no wrapper (it does not run the command) like print-arguments-wrapper.sh .
# It just prints the arguments and all environment variables it received, together with
# some other user-account information, and quits.
#
# Script version 1.03.
#
# Copyright (c) 2011-2022 R. Diez - Licensed under the GNU AGPLv3
use strict;
use warnings;
use Data::Dumper;
my $scriptName = $0;
$Data::Dumper::Terse = 1;
$Data::Dumper::Indent = 1;
$Data::Dumper::Sortkeys = 1;
$Data::Dumper::Quotekeys = 0;
$Data::Dumper::Useqq = 1;
sub write_stdout ( $ )
{
my $str = shift;
( print STDOUT $str ) or
die "Error writing to standard output: $!\n";
}
write_stdout( "Report from $scriptName:\n" );
write_stdout( "\n" );
my $realUserName = getpwuid( $< ) || "<unknown>";
my $effectiveUserName = getpwuid( $> ) || "<unknown>";
write_stdout( "Real user ID: $< ($realUserName)" . "\n" );
write_stdout( "Effective user ID: $> ($effectiveUserName)" . "\n" );
# write_stdout( "Real group IDs: $(\n" );
# write_stdout( "Effective group IDs: $)\n" );
write_stdout( "\n" );
write_stdout( "Real group IDs:\n" );
my @allRealGroupIds = split( /\s+/, $( );
foreach my $realGroupId ( @allRealGroupIds )
{
my $realGroupName = getgrgid( $realGroupId ) || "<unknown>";
write_stdout( "- $realGroupId ($realGroupName)\n" );
}
write_stdout( "\n" );
write_stdout( "Effective group IDs:\n" );
my @allEffectiveGroupIds = split( /\s+/, $) );
foreach my $effectiveGroupId ( @allEffectiveGroupIds )
{
my $effectiveGroupName = getgrgid( $effectiveGroupId ) || "<unknown>";
write_stdout( "- $effectiveGroupId ($effectiveGroupName)\n" );
}
write_stdout( "\n" );
write_stdout( "Environment variables, as seen by Perl's \%ENV variable:\n" . Dumper(\%ENV) . "\n" );
write_stdout( "Command-line arguments, as seen by Perl's \@ARGV variable:\n" );
if ( @ARGV == 0 )
{
write_stdout( "[No command-line arguments were passed]\n\n" );
}
else
{
write_stdout( Dumper(\@ARGV) . "\n" );
}
write_stdout( "Note that the above lists are in Perl syntax, so for example '\\\\' means a single '\\'.\n" );
write_stdout( "End of $scriptName.\n" );