Difference between revisions of "Scripting - Chapter 1: Getting to know Bash"
(Page créée avec « == Introduction == You would like to create your own scripts for PlayOnLinux but you don't know squat about programming? This tutorial will explain the basics and you'll... »)
m (RoninDusette a déplacé la page Scripting - Chapter 1 - Getting to know Bash vers Scripting - Chapter 1: Getting to know Bash)
Revision as of 22:11, 26 February 2015
You would like to create your own scripts for PlayOnLinux but you don't know squat about programming? This tutorial will explain the basics and you'll soon be a pro in playonlinuxian Bash.
Bash is a command interpretor (or "shell") in GNU/Linux and Mac OS X. It's the one appearing when you launch a terminal. It also allows you to make scripts. A script is a list of commands that your shell will execute one after the other. PlayOnLinux has advanced functions in Bash to make the scripting process easier. Let's get acquainted with them.
Requirements of every script
Every PlayOnLinux script must contain this boilerplate code:
- [ "$PLAYONLINUX" = "" ] && exit 0
- source "$PLAYONLINUX/lib/sources"
The above code may not make sense to you yet. We will explain what it does as we go.
During this tutorial, I will not repeat this code over and over in the examples, as you will need it in every script. Remember to always include it, otherwise your script won't work.
NOTE: Do not copy the line numbers to the script. It is recommended to type it out by hand while learning, as opposed to copying and pasting, so as to become more familiar with the scripting language.
Executing your script
Ask your favourite text editor to save your script, then use the function Run a local script from the Tools menu of PlayOnLinux.
PlayOnLinux uses digital signing (authentication) on scripts to certify that scripts have been validated by PlayOnLinux scripters. All the scripts available from the Install window of PlayOnLinux are validated. Each time you will try to run a script that has not been validated by PlayOnLinux scripters, you will get a warning message telling you that the script has no valid signature (see screenshot below).
You must click on Next button to get PlayOnLinux to show you the script source, then click on the I Agree checkbox, before you can (finally) run the script (see screenshot below).