Somehow my functions are not working and bing jumped to directly end stanza
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
**************************************************
Enabling HTTP Service
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
Starting Domain stat services..
./install.sh: line 220: runDomainStats: command not found
Setting Web Portal..
./install.sh: line 224: /etc/webmin/stop: No such file or directory
sed: can't read /etc/webmin/miniserv.conf: No such file or directory
sed: can't read /etc/webmin/miniserv.conf: No such file or directory
./install.sh: line 227: /etc/webmin/start: No such file or directory
Failed to issue method call: No such file or directory
Failed to issue method call: No such file or directory
Failed to issue method call: No such file or directory
Failed to issue method call: Unit elasticsearch.service failed to load: No such file or directory.
Failed to issue method call: Unit kibana.service failed to load: No such file or directory.
Failed to issue method call: Unit logstash.service failed to load: No such file or directory.
./install.sh: line 240: /usr/share/logstash/bin/logstash-plugin: No such file or directory
./install.sh: line 241: /usr/share/logstash/bin/logstash-plugin: No such file or directory
./install.sh: line 242: /usr/share/elasticsearch/bin/elasticsearch-plugin: No such file or directory
./install.sh: line 243: /usr/share/elasticsearch/bin/elasticsearch-plugin: No such file or directory
./install.sh: line 244: /usr/share/logstash/bin/logstash-plugin: No such file or directory
./install.sh: line 245: /usr/share/logstash/bin/logstash-plugin: No such file or directory
./install.sh: line 246: /usr/share/logstash/bin/logstash-plugin: No such file or directory
Last edited by astrogeek; 01-22-2018 at 02:07 PM.
Reason: Added CODE tags to improve readability
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
printMessage()
{
echo "this is function"
}
read -p "would you like to start? y/n" what
if [[ "$what" -eq 'y' ]] ;
then
echo "you entered $what"
else
echo "you entered $what"
fi
#executed once
printMessage
echo "in main"
#executed again, twice
printMessage
please edit your post and add code tags for easier reading.
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
#
# Define function named "testfunc"
testfunc(){
ls -l
}
Main script
# First output a line saying we're testing the function
echo Testing my function
# Now run the fuction
testfunc
@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
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.