Somehow my functions are not working and bing jumped to directly end stanza
Hi Guys,
I have a below script and somehow this is not working and even I have given the error but not sure why the certain functions are not getting executed. Can someone please help me here? Code:
################# Code:
************************************************** |
at the start where you ask y/n, and your over all structure of your script with usage of functions.
functions on top then call them when needed. Code:
#!/bin/bash edit: adding functions usage while post below posted about it... good call. |
You should define all functions near the beginning of the script.
Defining a function is much like creating a script within your script. Simply defining it does NOT "run" it. You have to call the function later in the script much as you would call another script. Code:
!/bin/bash |
@OP: As a start, edit your post and add the [code] and [/code] tags. Then remove everything that is not essential to show the problem. https://stackoverflow.com/help/mcve
Edit: Also read (preferably: learn by heart) this topic: https://www.linuxquestions.org/quest...gs-4175464257/ |
Agree!! and my apologies for that but I kept on writing script while testing each function while at the end something broke that I am not able to figure it out.
Any way let me see if i can define the functions and call them below in a sequence. |
DO NOT FORGET CODE TAGS! please and thank you.
|
As others have rightly said, in future please place your code snippets inside [CODE]...[/CODE] tags for better readability. You may type those yourself or click the "#" button in the edit controls. I have done that for you at this time.
Also, please try to reduce your problem to a simplest case which reproduces the error, and not ask others to read through a wall of unformatted text for details. This will demonstrate what you have done to troubleshoot the problem so far and help others to more quickly understand it and offer help. Very often in doing so you solve the problem in the process. Please review the Site FAQ for guidance in posting well formed questions and general forum usage. |
oh; and if you want to debug and see what is actually going wrong: "set -x" is such a nice thing to have around; be sure to remove / comment it out when you start using it for real... otherwise your terminal may explode.
|
All times are GMT -5. The time now is 08:25 AM. |