The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Multiple functions amitrajvarma Shell Programming and Scripting 1 11-27-2007 11:21 AM
Use of functions amitrajvarma Shell Programming and Scripting 1 11-23-2007 06:52 AM
ksh functions scriptingmani Shell Programming and Scripting 3 07-06-2007 07:15 AM
Regarding functions sendhilmani Shell Programming and Scripting 2 03-24-2006 04:40 AM
FTP functions hzambra High Level Programming 3 05-03-2002 01:06 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-20-2006
Raom Raom is offline
Registered User
  
 

Join Date: Sep 2005
Location: india
Posts: 79
functions in

hi
could anybody please suggest me how to put a function memory for particular user.
say i am a user rao. want have a function foo in memory .

i have done this .typed the function function in the shell it worked for the session.but next time i do login its not there .

i can i have a function forever in memory.
  #2 (permalink)  
Old 07-20-2006
reborg's Avatar
reborg reborg is online now Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,208
You will need to put it in you environment setup files. These depend on you shell. but you should find which one to use by looking at the man page for your shell and searching for FILES.
  #3 (permalink)  
Old 07-20-2006
Raom Raom is offline
Registered User
  
 

Join Date: Sep 2005
Location: india
Posts: 79
i am using kshell
  #4 (permalink)  
Old 07-20-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
In .profile add
Code:
foo()
{
     ls "$1" 
}
save the file.
next time you login try executing the function:
Code:
> foo somefilename
somefilename


If you login
  #5 (permalink)  
Old 07-21-2006
Raom Raom is offline
Registered User
  
 

Join Date: Sep 2005
Location: india
Posts: 79
thanks Jim.

but writing all the function in .profile looks no good i think.
i am lookin for a sophisticated way of writing functions probably the ENV file.

but not much aware of ENV file , if anybody knows please let me know.
  #6 (permalink)  
Old 07-21-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
What's wrong with jim's answer? Did you try to do it and did it fail?

The env that you are talking about is the environment of your process, and that is not kept in any file, but in memory. Once a process ends, its environment is lost as well. To make the function persistent across sessions, you have to define it somewhere and that somewhere is your .profile.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:47 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0