line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Goo::Environment; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# Nigel Hamilton |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
7
|
|
|
|
|
|
|
# All Rights Reserved |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
10
|
|
|
|
|
|
|
# Filename: Goo::Environment.pm |
11
|
|
|
|
|
|
|
# Description: Provide info about the environment the program is running in |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# Date Change |
14
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
# 07/06/2004 Auto generated file |
16
|
|
|
|
|
|
|
# 07/06/2004 needed to know the IP address of the current maching |
17
|
|
|
|
|
|
|
# 02/02/2005 Detect if we are in a CGI environment |
18
|
|
|
|
|
|
|
# 06/02/2005 Added test to see if this is a cronjob |
19
|
|
|
|
|
|
|
# 15/08/2005 Added method: getUser |
20
|
|
|
|
|
|
|
# 02/12/2005 Removed backticks from getIPAddress |
21
|
|
|
|
|
|
|
# |
22
|
|
|
|
|
|
|
############################################################################### |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
25
|
1
|
|
|
1
|
|
6
|
use Goo::Object; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
26
|
1
|
|
|
1
|
|
6
|
use base qw(Goo::Object); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
242
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
############################################################################### |
30
|
|
|
|
|
|
|
# |
31
|
|
|
|
|
|
|
# is_cgi - is this a cgi script? |
32
|
|
|
|
|
|
|
# |
33
|
|
|
|
|
|
|
############################################################################### |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub is_cgi { |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
0
|
1
|
|
return exists($ENV{'GATEWAY_INTERFACE'}); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
############################################################################### |
43
|
|
|
|
|
|
|
# |
44
|
|
|
|
|
|
|
# is_cronjob - is this running as a cronjob? |
45
|
|
|
|
|
|
|
# |
46
|
|
|
|
|
|
|
############################################################################### |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub is_cronjob { |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
0
|
1
|
|
return exists($ENV{'TERM'}); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
############################################################################### |
56
|
|
|
|
|
|
|
# |
57
|
|
|
|
|
|
|
# is_command_line - is this running on command line? |
58
|
|
|
|
|
|
|
# |
59
|
|
|
|
|
|
|
############################################################################### |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub is_command_line { |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
0
|
1
|
|
return exists($ENV{'TERM'}); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
############################################################################### |
69
|
|
|
|
|
|
|
# |
70
|
|
|
|
|
|
|
# get_ipaddress - which machine is this running on? |
71
|
|
|
|
|
|
|
# |
72
|
|
|
|
|
|
|
############################################################################### |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub get_ipaddress { |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
require Socket; |
79
|
0
|
|
|
|
|
|
require Sys::Hostname; |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
my $hostname = Sys::Hostname::hostname(); |
82
|
0
|
|
0
|
|
|
|
my $ip_address = Socket::inet_ntoa(scalar gethostbyname($hostname || |
83
|
|
|
|
|
|
|
'localhost') |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
return $ip_address; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
############################################################################### |
92
|
|
|
|
|
|
|
# |
93
|
|
|
|
|
|
|
# get_user - who is using this program? |
94
|
|
|
|
|
|
|
# |
95
|
|
|
|
|
|
|
############################################################################### |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub get_user { |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
0
|
1
|
|
return $ENV{'USER'}; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 NAME |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Goo::Environment - Provide details about the environment The Goo is running in |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 SYNOPSIS |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
use Goo::Environment; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 DESCRIPTION |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 METHODS |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=over |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item is_cgi |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
is this a cgi script? |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item is_cronjob |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
is this running as a cronjob? |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item is_command_line |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
is this running on command line? |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item get_ipaddress |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
which machine is this running on? |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item get_user |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
who is using this program? |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=back |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 AUTHOR |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 SEE ALSO |
151
|
|
|
|
|
|
|
|