- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Making functions in Korn Shell .
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-28-2005 04:27 AM
тАО12-28-2005 04:27 AM
i need make many scripts, for that reasen i need make many functions ... i'm going to do them in korn shell.
I remember in profile it must have a variable called FPATH i do not remember how declare it, could you tell me sintaxis please?
and, in this variable i know i have put the path where are going to be all functions, i remember only is necesary named the file like name function, is correct?
do i have make another thing?
do you know any manual o tutorial where it indicates how to create functions in korn shell?
thanks!! Manuales.
Solved! Go to Solution.
- Tags:
- function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-28-2005 04:41 AM
тАО12-28-2005 04:41 AM
SolutionFunctions are quite easy:
# my function
function myfunction
{
add code here
exit
}
Example:
function print_hp
{
Outpath=/var/spool/lp/receive
PSMServer=prdprt
# Strip path if any and take only filename
Filename=`echo $F | sed 's/.*\///'`
# Append filename to output file path
Fileout=$Outpath/${Filename}
rcp $F ${PSMServer}:$Outpath
rtc=$?
if test "$rtc" != 0
then
echo "Cannot move $F to $Fileout"
echo "Cannot move $F to $Fileout" 1>&2
exit $rtc
fi
# -d
remsh $PSMServer lp -d$P -n$C -p3 -onb $Fileout 1>&2
rtc=$?
if test "$rtc" != 0
then
echo "petroprt returned error code $rtc"
echo "petroprt returned error code $rtc" 1>&2
exit $rtc
fi
rm -f $4
#
return ${rtc}
Status=$?
if test "$Status" != 0
then
echo "Cannot print $F to $P"
echo "Cannot print $F to $P" 1>&2
exit $Status
fi
exit
}
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-28-2005 04:44 AM
тАО12-28-2005 04:44 AM
Re: Making functions in Korn Shell .
Then source it from your scripts:
FUNC_FILE=/usr/local/common.functions
# Source the files and functions
. $FUNC_FILE
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-28-2005 04:47 AM
тАО12-28-2005 04:47 AM
Re: Making functions in Korn Shell .
The manpages provide your first source of reference and answers:
http://www.docs.hp.com/en/B2355-60103/ksh.1.html
The Shell Users Guide is also a useful reference:
http://www.docs.hp.com/en/B2355-90046/B2355-90046.pdf
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-28-2005 05:06 AM
тАО12-28-2005 05:06 AM
Re: Making functions in Korn Shell .
i don't know where use typeset -fu, autoload, FPATH, ...
Thanks, Manuales.
- Tags:
- FPATH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-28-2005 05:13 AM
тАО12-28-2005 05:13 AM
Re: Making functions in Korn Shell .
THere is an interesting thread about ksh scripting here:
http://www.exforsys.com/forum/showthread.php?t=81773
Particulary, the rather long (but informative) post by Dan Mercer...
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-28-2005 05:37 AM
тАО12-28-2005 05:37 AM
Re: Making functions in Korn Shell .
i have the solution:
1st step:
in .profile file put:
FPATH=/.../../FUNCTIONS/
typeset -fu function_one
typeset -fu function_two
typeset -fu function_three
....
....
....
typeset -fu function_"n"
then, in path /.../../FUNCTION create new file, the name of this file must be same name in the function, for exammple:
======================
cat > function_one
function function_one
{
echo "Hi, this is a test"
}
ctrl + c
more function_one
function function_one
{
echo "Hi, this is a test"
}
======================
then since other file you must invoke it, for example, in a file named "verificando"
cat > verificando
#(1st step done)
. $HOME/.../../FUNCTIONS/.profile
functione_one
ctrl+c
cat verificando:
#(1st step done)
. $HOME/.../../FUNCTIONS/.profile
functione_one
Running script:
unix> ./verificando
Hi, this is a test
Thanks friends !!!
Manuales