In this video, we will look at a common problem that occurs when programming in BASH. This is the task of exchanging data between scripts written in BASH.
Part of it requires not just linear execution of commands, but some components that can be run from different parts of the code that can:
1. just execute something and then return control to the main bash creak that caused them. (Execution without receiving input parameters and transmitting received data.)
2. Get parameters when they are called, using them in your work.
3. Perform some calculations and transformations, while returning control to the BASH script that called them, the values of the variables obtained as a result.
It is important to solve these problems if you need to repeatedly execute the same type of code from different parts of the program. And of course, it is often important to accept the received data from a spent BASH script (and preferably directly in the form of variable values, rather than through text files).
It is also important to run the same piece of code, but with different parameters. And then there is a need to pass the called script, written in BASH, input parameters that it can use when executing its program.
At the beginning of the video, we perform additional actions, automating part of the work with running written programs in BASH.
When creating the video, there were errors in the code (which I later removed), but I did not cut this part (so that it was clear how real programs are written in General). Comments in the course of the video will tell you how to solve the errors that have occurred if someone encounters similar errors: when assigning a variable to a value, you CAN not put spaces before and after the = sign, otherwise the interpreter takes the variable name as a command, which of course the variable is not. And an error POPs up with the message that no command with this name was found.
To be continued! =)
USEFUL LINKS TO ARTICLES WITH DETAILED INSTRUCTIONS:
1. Articles on Bash programming - https://mb4.ru/programming/bash.html
2. Articles on Unix (using Debian as an example) - https://mb4.ru/operating-system/unix....
3. Articles about PuTTY - https://mb4.ru/programms/programs-for...
4. For those who decided to take their own server - https://mb4.ru/hosting/firstvds.html
For cooperation: https://mb4.ru/support.html
#Bash #programming #function #variable #command #error #subroutine #pass #accept #program #file