Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ksh: Trying to call function from another script

Status
Not open for further replies.

elpico

Programmer
May 14, 2003
19
0
0
GB
Hi all,
I'm getting problems accessing functions in ksh from other ksh files --- is there a way to do this? And does anyone have any suggestions to pass parameters from one script to another that has functions in it?

Basically I'm trying to avoid having tons of the same functions in every script I create.

A way I was trying to get around this was that inside script1 I would call script2 and pass a parameter to it -- Then inside script2 pick up the argument and test it using a case ---- but this gets a bit messy too...

Any suggestions/advice?
Thanks again,
elpico.

 
#-------------- script1.ksh
. script2.ksh
foo=$(ls . | wc -l)

sc1() {
sc2 "${foo}"
}




#---------- end of script1.ksh

#--------------- script2.ksh

sc2() {
echo "There're [${1}] files in your current dir."
}

#---------- end of script2.ksh


vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top