| | |
how to call a function from one file to another file
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2006
Posts: 2
Reputation:
Solved Threads: 0
hi,
i am having two files
n.sh
here i wrote code like
clear
f()
{
echo "this is my program to test function"
}
again
i am having one more file
n1.sh
here i wrote like this
./home/selvam (this is my program directory (ie.. actual n.sh file is in this directory}
again i am calling the function
f -> this is function calling . this function already defined in n.sh file
but i was run this script it shows the error as
n1.sh: f : the command not found
what is solution to this problem
help to me
thanks
i am having two files
n.sh
here i wrote code like
clear
f()
{
echo "this is my program to test function"
}
again
i am having one more file
n1.sh
here i wrote like this
./home/selvam (this is my program directory (ie.. actual n.sh file is in this directory}
again i am calling the function
f -> this is function calling . this function already defined in n.sh file
but i was run this script it shows the error as
n1.sh: f : the command not found
what is solution to this problem
help to me
thanks
if n.sh doesn't contain anything but functions and variables (i.e. no actual executed code) then add ". <path>/n.sh" to the top of n1.sh. If n.sh is a full functional script, then you cannot do this. If you have common functions that you wish to use over multiple scripts, then place these functions into their own file (preferable without a "#!" line at the top). In this way, every script that wants to use those functions can include them using the "." line presented earlier.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
•
•
Debugging code is twice as hard as writing it, so
by definition, if you code to the best of your ability,
you are not capable of debugging it.
(I don't remember who it was that said this or I would
acknowledge him.)
"Technological progress is like an axe in the hands of a pathological criminal."
All my posts may be freely redistributed under the terms of the MIT license.
All my posts may be freely redistributed under the terms of the MIT license.
I can't read that link (I am not a member of that site so it simply brings me to a login page).
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
From Dave_Sinulka's signature (CBoard member):
•
•
•
•
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
"Technological progress is like an axe in the hands of a pathological criminal."
All my posts may be freely redistributed under the terms of the MIT license.
All my posts may be freely redistributed under the terms of the MIT license.
![]() |
Similar Threads
- Warning: Unknown(): Unable to call () - function does not exist in Unknown on line 0 (PHP)
- how to call a function in href? (ASP.NET)
- "<SCRIPT SRC>" javascript logon help (JavaScript / DHTML / AJAX)
- Call Function (ASP.NET)
- How to call a perl script in the C# app? (C#)
- how to call this function...using menu..! (C++)
- Using a for loop to sum an integer n and call function add_it (C)
Other Threads in the Shell Scripting Forum
- Previous Thread: Shell Script Doubt.
- Next Thread: just to change directories...
| Thread Tools | Search this Thread |
Tag cloud for Shell Scripting






