LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 03-10-2009, 03:32 PM   #1
arashdx
LQ Newbie
 
Registered: Mar 2009
Posts: 1

Rep: Reputation: 0
Question bash function calling problem


hi guys
I'm new in linux and bash

I have 2 file
t1.sh & t2.sh

t2.sh
Code:
myFun(){
    echo "input is ${1}"
}
t1.sh
Code:
echo "say something"
read x
sh t2.sh
I want call myFun function from t1.sh file
NOTE:
I know how to invoke a function, the following code will work good


Code:
myFun(){
    echo "input is ${1}"
}
myFun ${1}
but I want call myFun() directly from t1.sh
i mean this
Code:
myFun(){
    echo "input is ${1}"
}
#myFun ${1} // invoke it from t1.sh, something like (myObject.myFun() in java )
how can i do this?
it drives me crazy
 
Old 03-10-2009, 03:42 PM   #2
TBC Cosmo
Member
 
Registered: Feb 2004
Location: NY
Distribution: Fedora 10, CentOS 5.4, Debian 5 Sparc64
Posts: 355

Rep: Reputation: 43
Quote:
Originally Posted by arashdx View Post
hi guys

I want call myFun function from t1.sh file

how can i do this?
in t1.sh, put this in the beginning.

. t2.sh

then call the function as you would if directly from t2.sh
 
  


Reply

Tags
bash, file, function


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
Calling a function in javascript mohtasham1983 Programming 4 03-04-2008 04:13 PM
calling a function from within another function in php jayakrishnan Programming 2 06-19-2007 08:36 AM
calling a function within a task manas_sem Programming 1 02-23-2007 03:51 PM
calling a function from a pointer spx2 Programming 3 05-25-2006 04:52 PM
Calling another function from a function using GTK geminigal Programming 4 07-11-2005 03:15 PM


All times are GMT -5. The time now is 11:15 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration