backup de julho
[h2N7SspZmY.git] / data / cache / 1 / 15e0e71ca14261669be189cf0bafeba8.xhtml
blob201180a2f72bef5a289297fd2b54e84f6272dd8e
4 <h1><a name="shell_script" id="shell_script">Shell Script</a></h1>
5 <div class="level1">
7 <p>
9 <a href="http://en.wikipedia.org/wiki/Shell_script" class="interwiki iw_wp" title="http://en.wikipedia.org/wiki/Shell_script">Shell Script</a>.
10 </p>
11 <div class="plugin_uparrow">
12 <a href="#" title="Back to top">
13 <img src="lib/plugins/uparrow/images/tango-small.png" alt="Back to top"/>
14 </a>
15 </div>
17 </div>
18 <!-- SECTION "Shell Script" [1-63] -->
19 <h2><a name="examples" id="examples">Examples</a></h2>
20 <div class="level2">
21 <dl class="file">
22 <dt><a href="/~kssilveira/site/doku.php?do=export_code&amp;id=main:shell_script&amp;codeblock=0" title="Download Snippet" class="mediafile mf_sh">run.sh</a></dt>
23 <dd><pre class="code file bash"><span class="co0">#!/bin/bash</span>
24 <span class="re2">dir_names</span>=<span class="br0">&#40;</span><span class="st0">&quot;tcp/null&quot;</span> <span class="st0">&quot;tcp/sort&quot;</span> <span class="st0">&quot;udp/null&quot;</span><span class="br0">&#41;</span>
25 <span class="kw1">for</span> d <span class="kw1">in</span> <span class="br0">&#123;</span>0..2<span class="br0">&#125;</span>
26 <span class="kw1">do</span>
27 <span class="re2">dir_name</span>=<span class="co1">${dir_names[$d]}</span>
28 <span class="kw3">echo</span> <span class="st0">&quot;<span class="es2">$dir_name</span>&quot;</span>
29 <span class="kw2">mv</span> <span class="st0">&quot;<span class="es2">$dir_name</span>/out.txt&quot;</span> <span class="st0">&quot;<span class="es2">$dir_name</span>/out.bak.txt&quot;</span>
30 <span class="kw1">for</span> j <span class="kw1">in</span> <span class="br0">&#123;</span>0..3<span class="br0">&#125;</span>
31 <span class="kw1">do</span>
32 <span class="co0">#echo &quot;$j&quot;</span>
33 <span class="kw1">for</span> i <span class="kw1">in</span> <span class="br0">&#123;</span>0..9<span class="br0">&#125;</span>
34 <span class="kw1">do</span>
35 <span class="co0">#echo &quot;$i&quot;</span>
36 <span class="kw1">if</span> <span class="br0">&#91;</span> <span class="st0">&quot;<span class="es2">$d</span>&quot;</span> = <span class="st0">&quot;8&quot;</span> <span class="br0">&#93;</span> <span class="sy0">||</span> <span class="br0">&#91;</span> <span class="st0">&quot;<span class="es2">$d</span>&quot;</span> = <span class="st0">&quot;9&quot;</span> <span class="br0">&#93;</span>
37 <span class="kw1">then</span>
38 <span class="kw3">cd</span> <span class="st0">&quot;<span class="es2">$dir_name</span>&quot;</span>
39 java Client 143.54.12.150:<span class="nu0">808</span><span class="st0">&quot;<span class="es2">$d</span>&quot;</span> <span class="sy0">&gt;&gt;</span> <span class="st0">&quot;out.txt&quot;</span>
40 <span class="kw3">cd</span> <span class="st0">&quot;../../&quot;</span>
41 <span class="kw1">else</span>
42 .<span class="sy0">/</span><span class="st0">&quot;<span class="es2">$dir_name</span>/client&quot;</span> 143.54.12.150 <span class="nu0">808</span><span class="st0">&quot;<span class="es2">$d</span>&quot;</span> <span class="sy0">&gt;&gt;</span> <span class="st0">&quot;<span class="es2">$dir_name</span>/out.txt&quot;</span>
43 <span class="kw1">fi</span>
44 <span class="kw1">done</span>
45 <span class="kw2">sleep</span> 60
46 <span class="kw1">done</span>
47 .<span class="sy0">/</span>calc.rb <span class="st0">&quot;<span class="es2">$dir_name</span>/out.txt&quot;</span>
48 <span class="kw1">done</span></pre>
49 </dd></dl>
50 <dl class="file">
51 <dt><a href="/~kssilveira/site/doku.php?do=export_code&amp;id=main:shell_script&amp;codeblock=1" title="Download Snippet" class="mediafile mf_sh">run_tests.sh</a></dt>
52 <dd><pre class="code file bash"><span class="co0">#!/bin/bash</span>
53 <span class="kw1">for</span> prog <span class="kw1">in</span> <span class="sy0">*</span>.pico
54 <span class="kw1">do</span>
55 <span class="kw3">echo</span> <span class="st0">&quot;<span class="es2">$prog</span>&quot;</span>
56 <span class="re2">prog_name</span>=<span class="co1">${prog%\.*}</span>
57 .<span class="sy0">/</span>run_test.sh <span class="st0">&quot;<span class="es2">$prog_name</span>&quot;</span>
58 <span class="kw1">done</span></pre>
59 </dd></dl>
60 <dl class="file">
61 <dt><a href="/~kssilveira/site/doku.php?do=export_code&amp;id=main:shell_script&amp;codeblock=2" title="Download Snippet" class="mediafile mf_sh">run_test.sh</a></dt>
62 <dd><pre class="code file bash"><span class="co0">#!/bin/bash</span>
63 <span class="kw1">if</span> <span class="kw3">test</span> <span class="re4">$#</span> <span class="re5">-ne</span> 1
64 <span class="kw1">then</span>
65 <span class="kw3">echo</span> <span class="st0">&quot;usage: $0 program_name&quot;</span>
66 <span class="kw3">echo</span> <span class="st0">&quot;given: $*&quot;</span>
67 <span class="kw1">else</span>
68 <span class="re2">prog_name</span>=$1
69 .<span class="sy0">/</span>..<span class="sy0">/</span>..<span class="sy0">/</span>src<span class="sy0">/</span>pico <span class="re5">-o</span> <span class="st0">&quot;<span class="es2">$prog_name</span>.tac&quot;</span> <span class="st0">&quot;<span class="es2">$prog_name</span>.pico&quot;</span>
70 <span class="kw1">fi</span></pre>
71 </dd></dl>
72 <div class="plugin_uparrow">
73 <a href="#" title="Back to top">
74 <img src="lib/plugins/uparrow/images/tango-small.png" alt="Back to top"/>
75 </a>
76 </div>
78 </div>
79 <!-- SECTION "Examples" [64-962] -->
80 <h2><a name="books" id="books">Books</a></h2>
81 <div class="level2">
83 <p>
84 <a href="/~kssilveira/site/lib/exe/fetch.php?media=main:canivete-shell.pdf" class="media mediafile mf_pdf" title="main:canivete-shell.pdf">Canivete Shell</a>
86 </p>
87 <div class="plugin_uparrow">
88 <a href="#" title="Back to top">
89 <img src="lib/plugins/uparrow/images/tango-small.png" alt="Back to top"/>
90 </a>
91 </div>
93 </div>
94 <!-- SECTION "Books" [963-] -->