LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 07-09-2010, 06:50 AM   #1
pinga123
Member
 
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Rep: Reputation: 37
Error Executing function.


Hi ,

I have written following code but its giving me two warning after execution.
What went wrong here?

Code:
function1()
{
echo "Hi"
}
function2()
{
echo $1
}
function3
{
echo "TATA"
}
function1
function2 "bye"
function3
Output

Code:
./sample.sh: line 9: function3: command not found
TATA
Hi
bye
./sample.sh: line 15: function3: command not found
Everything seems to be fine but why m i getting command not found.
 
Old 07-09-2010, 06:52 AM   #2
pinga123
Member
 
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Original Poster
Rep: Reputation: 37
I m sorry . I got my mistake .
 
Old 07-09-2010, 06:53 AM   #3
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,295

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
To make a function in shell, you should do it like this

function function1
{
echo "..."
}

http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-8.html
 
Old 07-10-2010, 12:57 AM   #4
pinga123
Member
 
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Original Poster
Rep: Reputation: 37
Quote:
Originally Posted by Guttorm View Post
To make a function in shell, you should do it like this

function function1
{
echo "..."
}

http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-8.html
the same thing can be written as
function1()
{
echo ".."
}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] g++ error message no matching function for call to some function Jerry Mcguire Programming 6 04-13-2010 09:37 PM
Shared Library Not Executing Function Osiris990 Programming 9 12-31-2007 05:51 AM
Error executing YUM sjyothi_12 Fedora 2 12-02-2006 09:34 AM
Error While Executing ChangeOfPace Linux - Networking 3 05-07-2004 09:49 AM
core dump while executing a c function from java using JNI kaustubh Linux - Newbie 0 05-25-2002 03:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration