haiku/docs/userguide/en/bash-scripting.html
Joachim Seemer 7c2cc28dc9 * Added input tolerance of DeskCalc, moved Terminal function to end of list
* Added CodyCam to list of apps in applications.html
* Added aligning tip for icons to tracker.html
* Added a few tips for working in Terminal
* Added a topic on scripting, linking to online resources
* Described function of UserBootscript an shutdown scripts


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29105 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-01-31 22:55:49 +00:00

82 lines
4.4 KiB
HTML

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"../../html-dtd/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<!--
*
* Copyright 2009, Haiku. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Humdinger <humdingerb@gmail.com>
*
-->
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="robots" content="all" />
<title>Bash and Scripting</title>
<link rel="stylesheet" type="text/css" href="../../Haiku-doc.css" />
</head>
<body>
<div class="logo">
<img src="../images/logo.png" alt="logo" width="372" height="86" />
<div class="title">Bash and Scripting</div>
</div>
<div class="topnav">
<p>
<a href="contents.html">Contents</a>
&#160;&#160;&#160;
Previous: <a href="preferences.html">Preferences</a>
<!-- &#160;&#160;&#160;
Next: <a href="filesystem-layout.html">Filesystem layout</a>
--> </p>
</div>
<div class="content">
<p>"Scripting" is the technique of automating procedures by stringing together commands and saving it all as text files, so called "scripts". Every time you run such a script, the commands are processed one after the other just like they would if you entered them into the <a href="applications/apps-terminal.html">Terminal</a> by hand.<br />
Scripts can range from simply executing a few commands in a specific order to sophisticated pieces of code that solve complex tasks.</p>
<h1><a id="bash" name="bash">The Bash</a></h1>
<p>Since scripts rely naturally a lot on the shell they are interpreted by, you should first familiarize yourself with the BASH that's used by Haiku. There are many resources online as it's a widely used shell. One nice document is Johan Jansson's <a href="http://www.beforever.com/bashtut.htm">Introduction to bash - a tutorial for bash under BeOS</a>.</p>
<h1><a id="scripting-bible" name="scripting-bible">The Scripting Bible</a></h1>
<p>After you've learned a few basics about working in the shell, it's time to slowly ease yourself into the world of scripting. Again, you'll find loads of tutorials and reference material online as well as in bookstores. A very nice introduction that's practically tailor-made for Haiku is the online available <a href="http://www.birdhouse.org/beos/bible/bos/ch_scripting1.html">Scripting Chapter</a> (<a href="http://www.birdhouse.org/beos/bible/bos/BeOS.scripting.PDF">PDF, 900kb</a>) of Scot Hacker's BeOS Bible.</p>
<h1><a id="user-scripts" name="user-scripts">Scripts in Haiku</a></h1>
<p>In Haiku, the system makes of course also use of scripting. Booting and shutting down are typical scripting procedures. These defined sequences can be augmented by the user with certain user scripts.<br />
If they don't exist already, you'll have to create the needed files yourself. Otherwise simply add your commands where in the process you want them to be executed.</p>
<h2><a id="userbootscript" name="userbootscript">The UserBootscript</a></h2>
<p><tt>/boot/home/config/boot/UserBootscript</tt> will be executed after the system has finished its boot process. For example, you could launch a number of programs that would then be automatically started on every boot up:</p>
<pre># Start LaunchBox
/boot/beos/apps/LaunchBox &amp;
# Start Workspaces Applet
/boot/beos/apps/Workspaces &amp;</pre>
<p>Remember to end a command with an "<tt>&amp;</tt>" to start it as a background process, or the script will halt until that command has finished (in this case: the launched app was closed again).</p>
<h2><a id="usershutdownscript" name="usershutdownscript">The UserShutdownScript</a></h2>
<p><tt>/boot/home/config/boot/UserShutdownScript</tt> will be executed as the first step in the shutdown process. If the script returns a non-zero exit status, the shutdown is aborted.</p>
<h2><a id="usershutdownfinishscript" name="usershutdownfinishscript">The UserShutdownFinishScript</a></h2>
<p><tt>/boot/home/config/boot/UserShutdownFinishScript</tt> is executed as the last step in the shutdown process. Note, that most parts of the system have terminated by the time this script is executed.</p>
</div>
<div class="bottomnav">
<p>
<a href="contents.html">Contents</a>
&#160;&#160;&#160;
Previous: <a href="preferences.html">Preferences</a>
<!-- &#160;&#160;&#160;
Next: <a href="filesystem-layout.html">Filesystem layout</a>
--> </p>
</div>
</body>
</html>