Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
Ive made a function and I cant seem to call it. it will run when I use it as a script, as soon as I make it a function glass()
{dls;ajgfl;dsajg;sl
gfdo;s'gkjfd'}
then I tried to put it into a script called run_glass
glass().
I get an error on line 4 doesnt recognize end of file. Basically I just put it into the file run_glass to see if it would run and it wouldnt. Do i need to put something before or after the function designation to get it to call and run properly? Hopefully this makes sense to someone. Thank you for reading
Can you post the actual code of your script for us? The gibberish text you typed in doesn't help one bit man... Not trying to be a d*ck either, but without seeing code, how can we help you troubleshoot?
LOL no offense taken, Hey I just want to help you help me. Here is the code all I want to do is be able to call this function into another script that only contains this function merely to prove the function can be called and works
glass()
{
echo "enter in a number: "
read a
echo "enter in another number: "
read b
echo "the number $a to the power of $b is"
expr ="$(( $a ** $b )) "
}
I used the parenthesis to let the OP that source was the command to use that would be used in importing a function from a different script. I didn't intend at all to mislead the OP......
I was talking about creating a function once you create it How do you add it to a script. Like for instance I want to run the function glass (that i created) in a script called run_glass. Where the only contents of the script run_glass is the glass function. how would I make that run? the script is above.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.