- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- create usable persistent function
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
тАО05-06-2005 02:49 AM
тАО05-06-2005 02:49 AM
When I create a function by pasting the code to create the function into a script and run the script, the script runs but when I try to execute the function, I get the message
ksh: get_time2: not found
However, if I just paste the code to the command line, it works.
For example:
oracle [/m02/oracle/scripts]
#get_time.ksh
oracle [/m02/oracle/scripts]
#get_time2
ksh: get_time2: not found.
oracle [/m02/oracle/scripts]
#more get_time.ksh
function get_time2 {
TIME=$(date '+%m/%d/%y-%H:%M:%S')
printf "$TIME\n"
}
oracle [/m02/oracle/scripts]
#function get_time2 {
> TIME=$(date '+%m/%d/%y-%H:%M:%S')
> printf "$TIME\n"
> }
oracle [/m02/oracle/scripts]
#get_time2
05/05/05-18:20:10
Question: how can I create the functions using code that executes within a shell script?
BTW the function doesn't seem to "be" anywhere in a physical location (does not appear in any searches of disk). And it is lost when you log out of your session.
Solved! Go to Solution.
- Tags:
- function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2005 02:52 AM
тАО05-06-2005 02:52 AM
Re: create usable persistent function
oracle [/m02/oracle/scripts]
# . get_time.ksh
- Tags:
- source
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2005 03:00 AM
тАО05-06-2005 03:00 AM
Re: create usable persistent function
Well, Amit, your reply solved part of the problem ... the function now creates from a script !
That is very much appreciated!!
The command I had to use differed slightly from yours:
. ./get_time.ksh
Next question is, how do you get a function to persist so that whenever you login, it is there ? The above got the function created for that session only. Logging in to box with another session, the function is not there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2005 03:17 AM
тАО05-06-2005 03:17 AM
Re: create usable persistent function
I found what I needed at the following webpage:
http://www.samag.com/documents/s=1153/sam0103f/0103f.htm
I see now that it has to be autoloaded from .kshrc at each logon.
Gil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2005 03:45 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-08-2005 12:53 PM
тАО05-08-2005 12:53 PM
Re: create usable persistent function
When you "dot" a file it is similar to executing a Windows style command file. It is as if you were entering the commands therin in sequence from the command line.
"man ksh" is a reasonable reference for this behaviour.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-08-2005 12:57 PM
тАО05-08-2005 12:57 PM