rbatch 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.ja.md +44 -25
- data/README.md +41 -27
- data/Rakefile +1 -1
- data/doc/rdoc/CHANGELOG.html +188 -144
- data/doc/rdoc/LICENSE.html +75 -79
- data/doc/rdoc/RBatch/Cmd.html +325 -293
- data/doc/rdoc/RBatch/CmdException.html +142 -141
- data/doc/rdoc/RBatch/CmdResult.html +471 -462
- data/doc/rdoc/RBatch/Config/Exception.html +2 -0
- data/doc/rdoc/RBatch/Config.html +331 -314
- data/doc/rdoc/RBatch/Log.html +766 -677
- data/doc/rdoc/RBatch.html +516 -425
- data/doc/rdoc/RBatchException.html +163 -0
- data/doc/rdoc/created.rid +8 -8
- data/doc/rdoc/index.html +125 -123
- data/doc/rdoc/lib/rbatch/cmd_rb.html +42 -42
- data/doc/rdoc/lib/rbatch/config_rb.html +42 -42
- data/doc/rdoc/lib/rbatch/log_rb.html +46 -44
- data/doc/rdoc/lib/rbatch_rb.html +46 -44
- data/doc/rdoc/rdoc.css +308 -365
- data/lib/rbatch/cmd.rb +14 -2
- data/lib/rbatch/log.rb +37 -10
- data/lib/rbatch.rb +23 -13
- data/sample/bin/test.rb +6 -0
- data/sample/bin/test2.rb +3 -0
- data/sample/log/20130131_apache_log_insert.log +23 -0
- data/sample/log/20130209_test.log +128 -0
- data/sample/log/20130210_test.log +68 -0
- data/test/cases/test_cmd.rb +12 -0
- metadata +8 -2
data/doc/rdoc/RBatch/Cmd.html
CHANGED
@@ -1,317 +1,349 @@
|
|
1
|
-
<?xml version="1.0" encoding="
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
2
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
-
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
4
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
5
|
<head>
|
6
|
-
|
6
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
7
7
|
|
8
|
-
|
8
|
+
<title>Class: RBatch::Cmd</title>
|
9
9
|
|
10
|
-
|
10
|
+
<link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
<script src="../js/jquery.js" type="text/javascript"
|
13
|
+
charset="utf-8"></script>
|
14
|
+
<script src="../js/thickbox-compressed.js" type="text/javascript"
|
15
|
+
charset="utf-8"></script>
|
16
|
+
<script src="../js/quicksearch.js" type="text/javascript"
|
17
|
+
charset="utf-8"></script>
|
18
|
+
<script src="../js/darkfish.js" type="text/javascript"
|
19
|
+
charset="utf-8"></script>
|
16
20
|
|
17
21
|
</head>
|
18
|
-
<body
|
22
|
+
<body class="class">
|
19
23
|
|
20
|
-
|
21
|
-
|
22
|
-
|
24
|
+
<div id="metadata">
|
25
|
+
<div id="home-metadata">
|
26
|
+
<div id="home-section" class="section">
|
23
27
|
<h3 class="section-header">
|
24
28
|
<a href="../index.html">Home</a>
|
25
29
|
<a href="../index.html#classes">Classes</a>
|
26
30
|
<a href="../index.html#methods">Methods</a>
|
27
31
|
</h3>
|
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
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
<p>
|
143
|
-
|
144
|
-
|
145
|
-
</li
|
146
|
-
<p>
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
</
|
151
|
-
<
|
152
|
-
|
153
|
-
|
154
|
-
</
|
155
|
-
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="file-metadata">
|
36
|
+
<div id="file-list-section" class="section">
|
37
|
+
<h3 class="section-header">In Files</h3>
|
38
|
+
<div class="section-body">
|
39
|
+
<ul>
|
40
|
+
|
41
|
+
<li><a href="../lib/rbatch/cmd_rb.html?TB_iframe=true&height=550&width=785"
|
42
|
+
class="thickbox" title="lib/rbatch/cmd.rb">lib/rbatch/cmd.rb</a></li>
|
43
|
+
|
44
|
+
</ul>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
|
48
|
+
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<div id="class-metadata">
|
52
|
+
|
53
|
+
<!-- Parent Class -->
|
54
|
+
|
55
|
+
<div id="parent-class-section" class="section">
|
56
|
+
<h3 class="section-header">Parent</h3>
|
57
|
+
|
58
|
+
<p class="link">Object</p>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
|
62
|
+
|
63
|
+
<!-- Namespace Contents -->
|
64
|
+
|
65
|
+
|
66
|
+
<!-- Method Quickref -->
|
67
|
+
|
68
|
+
<div id="method-list-section" class="section">
|
69
|
+
<h3 class="section-header">Methods</h3>
|
70
|
+
<ul class="link-list">
|
71
|
+
|
72
|
+
<li><a href="#method-c-new">::new</a></li>
|
73
|
+
|
74
|
+
<li><a href="#method-i-run">#run</a></li>
|
75
|
+
|
76
|
+
</ul>
|
77
|
+
</div>
|
78
|
+
|
79
|
+
|
80
|
+
<!-- Included Modules -->
|
81
|
+
|
82
|
+
</div>
|
83
|
+
|
84
|
+
<div id="project-metadata">
|
85
|
+
|
86
|
+
|
87
|
+
<div id="fileindex-section" class="section project-section">
|
88
|
+
<h3 class="section-header">Files</h3>
|
89
|
+
<ul>
|
90
|
+
|
91
|
+
<li class="file"><a href="../CHANGELOG.html">CHANGELOG</a></li>
|
92
|
+
|
93
|
+
<li class="file"><a href="../LICENSE.html">LICENSE</a></li>
|
94
|
+
|
95
|
+
</ul>
|
96
|
+
</div>
|
97
|
+
|
98
|
+
|
99
|
+
<div id="classindex-section" class="section project-section">
|
100
|
+
<h3 class="section-header">Class Index
|
101
|
+
<span class="search-toggle"><img src="../images/find.png"
|
102
|
+
height="16" width="16" alt="[+]"
|
103
|
+
title="show/hide quicksearch" /></span></h3>
|
104
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
105
|
+
<fieldset>
|
106
|
+
<legend>Quicksearch</legend>
|
107
|
+
<input type="text" name="quicksearch" value=""
|
108
|
+
class="quicksearch-field" />
|
109
|
+
</fieldset>
|
110
|
+
</form>
|
111
|
+
|
112
|
+
<ul class="link-list">
|
113
|
+
|
114
|
+
<li><a href="../RBatch.html">RBatch</a></li>
|
115
|
+
|
116
|
+
<li><a href="../RBatch/Cmd.html">RBatch::Cmd</a></li>
|
117
|
+
|
118
|
+
<li><a href="../RBatch/CmdException.html">RBatch::CmdException</a></li>
|
119
|
+
|
120
|
+
<li><a href="../RBatch/CmdResult.html">RBatch::CmdResult</a></li>
|
121
|
+
|
122
|
+
<li><a href="../RBatch/Config.html">RBatch::Config</a></li>
|
123
|
+
|
124
|
+
<li><a href="../RBatch/Config/Exception.html">RBatch::Config::Exception</a></li>
|
125
|
+
|
126
|
+
<li><a href="../RBatch/Log.html">RBatch::Log</a></li>
|
127
|
+
|
128
|
+
<li><a href="../RBatchException.html">RBatchException</a></li>
|
129
|
+
|
130
|
+
</ul>
|
131
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
132
|
+
</div>
|
133
|
+
|
134
|
+
|
135
|
+
</div>
|
136
|
+
</div>
|
137
|
+
|
138
|
+
<div id="documentation">
|
139
|
+
<h1 class="class">RBatch::Cmd</h1>
|
140
|
+
|
141
|
+
<div id="description">
|
142
|
+
<p>
|
143
|
+
External command runcher.
|
144
|
+
</p>
|
145
|
+
<ul>
|
146
|
+
<li><p>
|
147
|
+
Input cmd_params into Kernel#spawn.
|
148
|
+
</p>
|
149
|
+
</li>
|
150
|
+
<li><p>
|
151
|
+
Write command’s stdout and stderr to tmp file.
|
152
|
+
</p>
|
153
|
+
</li>
|
154
|
+
</ul>
|
155
|
+
<pre>
|
156
|
+
* If Platform is "mswin" or "mingw" , then temp directory is ENV["TEMP"]
|
157
|
+
* If Platform is "linux" or "cygwin" , then temp directory is "/tmp/"
|
158
|
+
</pre>
|
159
|
+
<ul>
|
160
|
+
<li><p>
|
161
|
+
Return hash object including stdout, stderr, and exit status.
|
162
|
+
</p>
|
163
|
+
</li>
|
164
|
+
</ul>
|
156
165
|
<h4>Sample 1</h4>
|
157
|
-
|
158
|
-
|
159
|
-
cmd = RBatch::Cmd("ls")
|
160
|
-
r = cmd.run
|
161
|
-
p r.stdout
|
162
|
-
=> "fileA\nfileB\n"
|
163
|
-
|
166
|
+
<pre>
|
167
|
+
require 'rbatch'
|
168
|
+
cmd = RBatch::Cmd("ls")
|
169
|
+
r = cmd.run
|
170
|
+
p r.stdout
|
171
|
+
=> "fileA\nfileB\n"
|
172
|
+
</pre>
|
164
173
|
<h4>Sample 2 ( Use option)</h4>
|
165
|
-
|
166
|
-
|
167
|
-
r = cmd.run
|
168
|
-
|
174
|
+
<pre>
|
175
|
+
cmd = RBatch::Cmd("ls", {:verbose => true})
|
176
|
+
r = cmd.run
|
177
|
+
</pre>
|
169
178
|
<h4>Sample 3 ( Use alias)</h4>
|
170
|
-
|
171
|
-
|
172
|
-
r = RBatch::cmd("ls")
|
173
|
-
p r.stdout
|
174
|
-
=> "fileA\nfileB\n"</pre>
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
<div class="method-description">
|
208
|
-
|
209
|
-
<p><a href="Cmd.html">Cmd</a> instance</p>
|
210
|
-
|
179
|
+
<pre>
|
180
|
+
require 'rbatch'
|
181
|
+
r = RBatch::cmd("ls")
|
182
|
+
p r.stdout
|
183
|
+
=> "fileA\nfileB\n"</pre>
|
184
|
+
|
185
|
+
</div>
|
186
|
+
|
187
|
+
<!-- Constants -->
|
188
|
+
|
189
|
+
|
190
|
+
<!-- Attributes -->
|
191
|
+
|
192
|
+
|
193
|
+
<!-- Methods -->
|
194
|
+
|
195
|
+
<div id="public-class-method-details" class="method-section section">
|
196
|
+
<h3 class="section-header">Public Class Methods</h3>
|
197
|
+
|
198
|
+
|
199
|
+
<div id="new-method" class="method-detail ">
|
200
|
+
<a name="method-c-new"></a>
|
201
|
+
|
202
|
+
<div class="method-heading">
|
203
|
+
|
204
|
+
<span class="method-name">new</span><span
|
205
|
+
class="method-args">(cmd_str,opt = nil)</span>
|
206
|
+
<span class="method-click-advice">click to toggle source</span>
|
207
|
+
|
208
|
+
</div>
|
209
|
+
|
210
|
+
<div class="method-description">
|
211
|
+
|
212
|
+
<p>
|
213
|
+
<a href="Cmd.html">Cmd</a> instance
|
214
|
+
</p>
|
211
215
|
<h4>Params</h4>
|
212
|
-
|
213
|
-
<
|
214
|
-
hash object. Hash keys is follows
|
215
|
-
|
216
|
-
<
|
217
|
-
|
218
|
-
</
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
216
|
+
<p>
|
217
|
+
<tt>cmd_str</tt> = Command string. Such ad “ls -l” <tt>opt</tt>
|
218
|
+
= Option hash object. Hash keys is follows.
|
219
|
+
</p>
|
220
|
+
<ul>
|
221
|
+
<li><p>
|
222
|
+
<tt>:raise</tt> (Boolean) = If command exit status is not 0, raise
|
223
|
+
exception. Default is false.
|
224
|
+
</p>
|
225
|
+
</li>
|
226
|
+
<li><p>
|
227
|
+
<tt>:timeout</tt> (Integer) = If command timeout , raise exception. Default
|
228
|
+
is 0 sec ( 0 means disable) .
|
229
|
+
</p>
|
230
|
+
</li>
|
231
|
+
</ul>
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
<div class="method-source-code"
|
236
|
+
id="new-source">
|
223
237
|
<pre>
|
224
|
-
<span class="ruby-comment"># File lib/rbatch/cmd.rb, line
|
225
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">cmd_str</span>,<span class="ruby-identifier">opt</span> = <span class="ruby-keyword">nil</span>)
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
<span class="ruby-keyword">end</span></pre>
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
238
|
+
<span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 46</span>
|
239
|
+
46: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">cmd_str</span>,<span class="ruby-identifier">opt</span> = <span class="ruby-keyword kw">nil</span>)
|
240
|
+
47: <span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-value str">"Command string is nil"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cmd_str</span>.<span class="ruby-identifier">nil?</span>
|
241
|
+
48: <span class="ruby-ivar">@cmd_str</span> = <span class="ruby-identifier">cmd_str</span>
|
242
|
+
49: <span class="ruby-comment cmt"># parse option</span>
|
243
|
+
50: <span class="ruby-ivar">@opt</span> = <span class="ruby-identifier">@@def_opt</span>.<span class="ruby-identifier">clone</span>
|
244
|
+
51: <span class="ruby-identifier">@@def_opt</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
|
245
|
+
52: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opt</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">opt</span>[<span class="ruby-identifier">key</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
246
|
+
53: <span class="ruby-comment cmt"># use argument</span>
|
247
|
+
54: <span class="ruby-ivar">@opt</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">opt</span>[<span class="ruby-identifier">key</span>]
|
248
|
+
55: <span class="ruby-keyword kw">elsif</span> <span class="ruby-constant">RBatch</span>.<span class="ruby-identifier">common_config</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">&&</span> <span class="ruby-constant">RBatch</span>.<span class="ruby-identifier">common_config</span>[<span class="ruby-value str">"cmd_"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
249
|
+
56: <span class="ruby-comment cmt"># use config</span>
|
250
|
+
57: <span class="ruby-ivar">@opt</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-constant">RBatch</span>.<span class="ruby-identifier">common_config</span>[<span class="ruby-value str">"cmd_"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>]
|
251
|
+
58: <span class="ruby-keyword kw">else</span>
|
252
|
+
59: <span class="ruby-comment cmt"># use default</span>
|
253
|
+
60: <span class="ruby-keyword kw">end</span>
|
254
|
+
61: <span class="ruby-keyword kw">end</span>
|
255
|
+
62: <span class="ruby-keyword kw">end</span></pre>
|
256
|
+
</div>
|
257
|
+
|
258
|
+
</div>
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
</div>
|
264
|
+
|
265
|
+
|
266
|
+
</div>
|
267
|
+
|
268
|
+
<div id="public-instance-method-details" class="method-section section">
|
269
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
270
|
+
|
271
|
+
|
272
|
+
<div id="run-method" class="method-detail ">
|
273
|
+
<a name="method-i-run"></a>
|
274
|
+
|
275
|
+
<div class="method-heading">
|
276
|
+
|
277
|
+
<span class="method-name">run</span><span
|
278
|
+
class="method-args">()</span>
|
279
|
+
<span class="method-click-advice">click to toggle source</span>
|
280
|
+
|
281
|
+
</div>
|
282
|
+
|
283
|
+
<div class="method-description">
|
284
|
+
|
285
|
+
<p>
|
286
|
+
Run command
|
287
|
+
</p>
|
273
288
|
<h4>Return</h4>
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
289
|
+
<p>
|
290
|
+
instance of <a href="CmdResult.html">RBatch::CmdResult</a>
|
291
|
+
</p>
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
<div class="method-source-code"
|
296
|
+
id="run-source">
|
280
297
|
<pre>
|
281
|
-
<span class="ruby-comment"># File lib/rbatch/cmd.rb, line
|
282
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">run</span>()
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
<span class="ruby-keyword">end</span
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
298
|
+
<span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 69</span>
|
299
|
+
69: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>()
|
300
|
+
70: <span class="ruby-identifier">stdout_file</span> = <span class="ruby-constant">Tempfile</span><span class="ruby-operator">::</span><span class="ruby-identifier">new</span>(<span class="ruby-value str">"rbatch_tmpout"</span>,<span class="ruby-constant">RBatch</span><span class="ruby-operator">::</span><span class="ruby-identifier">tmp_dir</span>)
|
301
|
+
71: <span class="ruby-identifier">stderr_file</span> = <span class="ruby-constant">Tempfile</span><span class="ruby-operator">::</span><span class="ruby-identifier">new</span>(<span class="ruby-value str">"rbatch_tmperr"</span>,<span class="ruby-constant">RBatch</span><span class="ruby-operator">::</span><span class="ruby-identifier">tmp_dir</span>)
|
302
|
+
72: <span class="ruby-identifier">pid</span> = <span class="ruby-identifier">spawn</span>(<span class="ruby-ivar">@cmd_str</span>,<span class="ruby-value">:out</span> =<span class="ruby-operator">></span> [<span class="ruby-identifier">stdout_file</span>,<span class="ruby-value str">"w"</span>],<span class="ruby-value">:err</span> =<span class="ruby-operator">></span> [<span class="ruby-identifier">stderr_file</span>,<span class="ruby-value str">"w"</span>])
|
303
|
+
73: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@opt</span>[<span class="ruby-value">:timeout</span>] <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>
|
304
|
+
74: <span class="ruby-identifier">timeout</span>(<span class="ruby-ivar">@opt</span>[<span class="ruby-value">:timeout</span>]) <span class="ruby-keyword kw">do</span>
|
305
|
+
75: <span class="ruby-keyword kw">begin</span>
|
306
|
+
76: <span class="ruby-identifier">status</span> = <span class="ruby-constant">Process</span>.<span class="ruby-identifier">waitpid2</span>(<span class="ruby-identifier">pid</span>)[<span class="ruby-value">1</span>] <span class="ruby-operator">>></span> <span class="ruby-value">8</span>
|
307
|
+
77: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Timeout</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
308
|
+
78: <span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-value str">"Command timeout (over "</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@opt</span>[<span class="ruby-value">:timeout</span>] <span class="ruby-operator">+</span> <span class="ruby-value str">" sec)"</span> )
|
309
|
+
79: <span class="ruby-keyword kw">end</span>
|
310
|
+
80: <span class="ruby-keyword kw">end</span>
|
311
|
+
81: <span class="ruby-keyword kw">else</span>
|
312
|
+
82: <span class="ruby-identifier">status</span> = <span class="ruby-constant">Process</span>.<span class="ruby-identifier">waitpid2</span>(<span class="ruby-identifier">pid</span>)[<span class="ruby-value">1</span>] <span class="ruby-operator">>></span> <span class="ruby-value">8</span>
|
313
|
+
83: <span class="ruby-keyword kw">end</span>
|
314
|
+
84: <span class="ruby-identifier">result</span> = <span class="ruby-constant">RBatch</span><span class="ruby-operator">::</span><span class="ruby-constant">CmdResult</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">stdout_file</span>,<span class="ruby-identifier">stderr_file</span>,<span class="ruby-identifier">status</span>,<span class="ruby-ivar">@cmd_str</span>)
|
315
|
+
85: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@opt</span>[<span class="ruby-value">:raise</span>] <span class="ruby-operator">&&</span> <span class="ruby-identifier">status</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>
|
316
|
+
86: <span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-value str">"Command exit status is not 0. result: "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">to_s</span>)
|
317
|
+
87: <span class="ruby-keyword kw">end</span>
|
318
|
+
88: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>
|
319
|
+
89: <span class="ruby-keyword kw">end</span></pre>
|
320
|
+
</div>
|
321
|
+
|
322
|
+
</div>
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
</div>
|
328
|
+
|
329
|
+
|
330
|
+
</div>
|
331
|
+
|
332
|
+
|
333
|
+
</div>
|
334
|
+
|
335
|
+
|
336
|
+
<div id="rdoc-debugging-section-dump" class="debugging-section">
|
337
|
+
|
338
|
+
<p>Disabled; run with --debug to generate this.</p>
|
339
|
+
|
340
|
+
</div>
|
341
|
+
|
342
|
+
<div id="validator-badges">
|
343
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
344
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
345
|
+
Rdoc Generator</a> 1.1.6</small>.</p>
|
346
|
+
</div>
|
315
347
|
|
316
348
|
</body>
|
317
349
|
</html>
|