![]() Before we can execute a script it must have the execute permission set (for safety reasons this permission is generally not set by default). Another term you may come across is executing the script (which means the same thing). For the most part you don't need to worry too much about this phenomenon however. We'll demonstrate this in the next section on variables and it's implications should become clearer. If we start a script running it doesn't actually run in that process but instead starts a new process to run inside. When we are at the terminal we have a Bash process running in order to give us the Bash shell. Once they are finished running the system then destroys them and there are no longer any processes representing the program cp. In this case there would be two cp processes currently existing on the system. For example I could have two terminals open and be running the command cp in both of them. There could be several processes representing the same program running in memory at the same time. We also allocate a bit of space in RAM for the process to store variables (to hold temporary working data) and a few flags to allow the operating system (OS) to manage and track the process during it's execution.Įssentially a process is a running instance of a program. What we do is copy those instructions and resources from the hard disk into working memory (or RAM). When we say we are running a program we are not really running the program but a copy of it which is called a process. A program is a blob of binary data consisting of a series of instructions for the CPU and possibly other resources (images, sound files and such) organised into a package and typically stored on your hard disk. In the realm of Linux (and computers in general) we have the concept of programs and processes. It's not necessary to understand this in order to write scripts but it can be useful to know once you start getting into more complex scripts (and scripts that call and rely on other scripts once you start getting really fancy). This is just a little bit of background knowledge. As you would be aware (and if you're not maybe you should consider reviewing our Linux Tutorial), Linux is an extensionless system so a script doesn't necessarily have to have this characteristic in order to work. It is convention to give files that are Bash scripts an extension of. In this sense, if you know how to do stuff at the command line then you already know a fair bit in terms of Bash scripting. It's just that instead of typing them at the command line we are now entering them into a plain text file. Just type the commands as you would normally and they will behave as they would normally. Similarly, anything you can put into a script can also be run normally on the command line and it will do exactly the same thing. ![]() An important point to remember though is:Īnything you can run normally on the command line can be put into a script and it will do exactly the same thing. These commands are a mixture of commands we would normally type ouselves on the command line (such as ls or cp for example) and commands we could type on the command line but generally wouldn't (you'll discover these over the next few pages). In the context of Bash scripts we are telling the Bash shell what it should do.Ī Bash script is a plain text file which contains a series of commands. A script for a computer tells the computer what it should do or say. The script tells the actors what they should say and do. Think of a script for a play, or a movie, or a TV show. Taking the time to read and understand the material in this section will make the other sections easier to digest so persevere and it'll be well worth your time. It's kinda boring but essential stuff that will help you to appreciate why and how certian things behave the way they do once we start playing about with the fun stuff (which I promise we'll do in the next section). ![]() This page is mostly foundation information.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |