- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- invoking a function with parameter
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
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
тАО10-14-2003 08:46 PM
тАО10-14-2003 08:46 PM
how to invoke a function so it takes certain values as parameters?
the point is: i've got a function that work with two variables (v1, v2). i'd like to make it work each time with different values of these variables. where should the function take values from (command line? file?)
how to make it work?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2003 08:49 PM
тАО10-14-2003 08:49 PM
Re: invoking a function with parameter
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2003 08:53 PM
тАО10-14-2003 08:53 PM
Re: invoking a function with parameter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2003 08:59 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2003 09:00 PM
тАО10-14-2003 09:00 PM
Re: invoking a function with parameter
v1=3
v2=7
echo $v1
3
echo $v2
7
hth
J
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2003 09:02 PM
тАО10-14-2003 09:02 PM
Re: invoking a function with parameter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2003 09:04 PM
тАО10-14-2003 09:04 PM
Re: invoking a function with parameter
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=233360
--
Anyway, within the function, just refer to $1, $2 as your parameters, and call it using syntax "yourfunc p1, p2".
Example: function leave takes an optional single parameter
--
function leave {
[ -n "$1" ] && exit_cd=$1
exit $exit_cd
}
-- and can be called in 2 ways --
leave 1
leave
--
--Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2003 09:10 PM
тАО10-14-2003 09:10 PM
Re: invoking a function with parameter
function addten {
b=`expr $1 + 10`
echo "$1 plus 10 is $b"
}
for i in 10 23 4 65
do
addten $i
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2003 09:20 PM
тАО10-14-2003 09:20 PM