1 SVCPROP(1) User Commands SVCPROP(1)
2
3
4
5 NAME
6 svcprop - retrieve values of service configuration properties
7
8 SYNOPSIS
9 svcprop [-fqtv] [-C | -c | -s snapshot]
10 [-z zone] [-p [name/]name]...
11 {FMRI | pattern}...
12
13
14 svcprop -w [-fqtv] [-z zone] [-p [name/]name] {FMRI | pattern}
15
16
17 DESCRIPTION
18 The svcprop utility prints values of properties in the service
19 configuration repository. Properties are selected by -p options and the
20 operands.
21
22
23 Without the -C, -c, or -s options, svcprop accesses effective
24 properties. The effective properties of a service are its directly
25 attached properties. The effective properties of a service instance are
26 the union of properties in the composed view of its running snapshot
27 and the properties in nonpersistent property groups in the composed
28 view of the instance's directly attached properties. See smf(5) for an
29 explanation of property composition. If the running snapshot does not
30 exist then the instance's directly attached properties are used
31 instead.
32
33 Output Format
34 By default, when a single property is selected, the values for each are
35 printed on separate lines. Empty ASCII string values are represented by
36 a pair of double quotes (""). Bourne shell metacharacters (';', '&',
37 '(', ')', '|', '^', '<', '>', newline, space, tab, backslash, '"',
38 single-quote, '`') in ASCII string values are quoted by backslashes
39 (\).
40
41
42 When multiple properties are selected, a single line is printed for
43 each. Each line comprises a property designator, a property type, and
44 the values (as described above), separated by spaces. By default, if a
45 single FMRI operand has been supplied, the property designator consists
46 of the property group name and the property name joined by a slash (/).
47 If multiple FMRI operands are supplied, the designator is the canonical
48 FMRI for the property.
49
50
51 If access controls prohibit reading the value of a property, and no
52 property or property group is specified explicitly by a -p option, the
53 property is displayed as if it had no values. If one or more property
54 or property group names is specified by a -p option, and any property
55 value cannot be read due to access controls, an error results.
56
57
58 Error messages are printed to the standard error stream.
59
60 OPTIONS
61 The following options are supported:
62
63 -C
64 Uses the directly attached properties, without
65 composition.
66
67
68 -c
69 For service instances, uses the composed view of their
70 directly attached properties.
71
72
73 -f
74 Selects the multi-property output format, with full FMRIs
75 as designators.
76
77
78 -p name
79 For each service or service instance specified by the
80 operands, selects all properties in the name property
81 group. For property groups specified by the operands,
82 selects the name property.
83
84
85 -p pg/prop
86 Selects property prop in property group pg for each of
87 the services or service instances specified by the
88 operands.
89
90
91 -q
92 Quiet. Produces no output.
93
94
95 -s name
96 Uses the composed view of the name snapshot for service
97 instances.
98
99
100 -t
101 Selects the multi-property output format.
102
103
104 -v
105 Verbose. Prints error messages for nonexistent
106 properties, even if option -q is also used.
107
108
109 -w
110 Waits until the specified property group or the property
111 group containing the specified property changes before
112 printing.
113
114 This option is only valid when a single entity is
115 specified. If more than one operand is specified, or an
116 operand matches more than one instance, an error message
117 is printed and no action is taken. The -C option is
118 implied.
119
120
121 -z zone
122 Uses properties from the service or instance in the
123 specified zone. This option is only applicable from the
124 global zone, see zones(5).
125
126
127 OPERANDS
128 The following operands are supported:
129
130 FMRI
131 The FMRI of a service, a service instance, a property group,
132 or a property.
133
134 Instances and services can be abbreviated by specifying the
135 instance name, or the trailing portion of the service name.
136 Properties and property groups must be specified by a full
137 FMRI. For example, given the FMRI:
138
139 svc:/network/smtp:sendmail
140
141
142 The following are valid abbreviations:
143
144 sendmail
145 :sendmail
146 smtp
147 smtp:sendmail
148 network/smtp
149
150
151 The following are invalid abbreviations:
152
153 mail
154 network
155 network/smt
156
157
158 Abbreviated forms of FMRIs are unstable and should not be
159 used in scripts or other permanent tools. If an abbreviation
160 matches multiple instances, svcprop acts on each instance.
161
162
163 pattern
164 A glob pattern which is matched against the FMRIs of
165 services and instances in the repository. See fnmatch(5). If
166 a pattern matches multiple services or instances, svcprop
167 acts on each service or instance.
168
169
170 EXAMPLES
171 Example 1 Displaying the Value of a Single Property
172
173
174 The following example displays the value of the state property in the
175 restarter property group of instance default of service system/cron.
176
177
178 example% svcprop -p restarter/state system/cron:default
179 online
180
181
182
183 Example 2 Retrieving Whether a Service is Enabled
184
185
186 Whether a service is enabled is determined by its -general/enabled
187 property. This property takes immediate effect, so the -c option must
188 be used:
189
190
191 example% svcprop -c -p general/enabled system/cron:default
192 true
193
194
195
196 Example 3 Displaying All Properties in a Property Group
197
198
199 On a default installation of Solaris, the following example displays
200 all properties in the general property group of each instance of the
201 network/ntp service:
202
203
204 example% svcprop -p general ntp
205 general/package astring SUNWntpr
206 general/enabled boolean true
207 general/entity_stability astring Unstable
208
209
210
211 Example 4 Testing the Existence of a Property
212
213
214 The following example tests the existence of the general/enabled
215 property for all instances of service identity:
216
217
218 example% svcprop -q -p general/enabled identity:
219 example% echo $?
220 0
221
222
223
224 Example 5 Waiting for Property Change
225
226
227 The following example waits for the sendmail instance to change state.
228
229
230 example% svcprop -w -p restarter/state sendmail
231
232
233
234 Example 6 Retrieving the Value of a Boolean Property in a Script
235
236
237 The following example retrieves the value of a boolean property in a
238 script:
239
240
241 set -- `svcprop -c -t -p general/enabled service`
242 code=$?
243 if [ $code -ne 0 ]; then
244 echo "svcprop failed with exit code $code"
245 return 1
246 fi
247 if [ $2 != boolean ]; then
248 echo "general/enabled has unexpected type $2"
249 return 2
250 fi
251 if [ $# -ne 3 ]; then
252 echo "general/enabled has wrong number of values"
253 return 3
254 fi
255 value=$3
256 ...
257
258
259
260 Example 7 Using svcprop in a Script
261
262 example% cat getval
263 #!/bin/sh
264
265 svcprop -p $1 $2 | (
266 read value v2
267 if [ -n "$v2" ]; then echo "Multiple values!"; exit; fi
268 echo $value
269 )
270
271
272
273 EXIT STATUS
274 The following exit values are returned:
275
276 0
277 Successful completion.
278
279
280 1
281 An error occurred.
282
283
284 2
285 Invalid command line options were specified.
286
287
288 SEE ALSO
289 svcs(1), inetd(1M), svcadm(1M), svccfg(1M), svc.startd(1M),
290 service_bundle(4), attributes(5), fnmatch(5), smf(5), smf_method(5),
291 smf_security(5), zones(5)
292
293
294
295 December 11, 2019 SVCPROP(1)