How to use functions as a system commands?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to use functions as a system commands?
# 1  
Old 04-11-2012
How to use functions as a system commands?

I have few functions which do some things which i have programmed to do. I want them to use that functions anytime i want. Right now if i need to use that function i have to copied that to putty and then call that function. Is it possible to do that so that i don't need to call that function. And i can use that function like unix commands.



Thanks for your help.

pdSmilie
# 2  
Old 04-11-2012
It is a little unclear what you want. I am guessing that you have written some functions that you might want to call from the shell command prompt any time, rather than having to write a script, define them in there and call them how you need each time.

I think that if you have these functions in a file (let's call it myfunctions) then you are wanting to make them available to the current shell. Try:-
Code:
. myfunctions

The leading "dot space" is important. This will execute the myfunctions file and load any functions to the current shell, so if you had:-
Code:
#myfunctions file
first()
{
 echo "Good morning!"
}

second()
{
 echo "Good afternoon!"
}

Then you could do the following:-
Code:
$ .  myfunctions
$ first
Good morning!
$ second
Good afternoon!
$

Is that the sort of thing you are after? If not, then do reply and explain where I have completely missed the point.



I hope that this helps
Robin
Liverpool/Blackburn
UK
# 3  
Old 04-11-2012
MySQL Thanks a lot

Thanks Robin,

That what i want.

Thanks a lot

pd
# 4  
Old 04-11-2012
You are welcome. As it is 14:10 GMT, please run my function called second


Robin
Liverpool/Blackburn
UK
These 2 Users Gave Thanks to rbatte1 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

File System & commands

Hello! Is File System stored in unix kernel or in pc memory? Are unix commands stored in kernel? many thanks! (1 Reply)
Discussion started by: pinklemon
1 Replies

2. Shell Programming and Scripting

How to execute functions or initiate functions as command line parameters for below requirement?

I have 7 functions those need to be executed as command line inputs, I tried with below code it’s not executing function. If I run the ./script 2 then fun2 should execute , how to initiate that function I tried case and if else also, how to initiate function from command line if then... (8 Replies)
Discussion started by: saku
8 Replies

3. Programming

man pages for commands and functions of same name?

Hi friends, I hope everyone is fine and doing well. I am facing this irritating problem. As you know that manual pages are available for both unix commands and c functions. Now when I try to check the manual pages for functions like read write exit I get the manual pages for the... (3 Replies)
Discussion started by: gabam
3 Replies

4. Shell Programming and Scripting

how to fetch the commands at solaris system

:wall:i'm system administrator. now i have a trouble. i want to fetch the command which the login users performed by shell.but i don't know how to process this problem.if anyone tell me how to do this work I would be very grateful.thank you! (4 Replies)
Discussion started by: anline5104
4 Replies

5. Programming

Difference between system calls and normal functions in C

hello all, i'm a beginner in linux programming. I need to know what is the difference between system calls and normal functions like fopen, fread etc in C?Also how to set permissions by using open system call? (11 Replies)
Discussion started by: aarathy
11 Replies

6. Linux

commands of linux operation system

Am actually am new to the linux operating system and knda wana knw more about it.Please could u help me with some commands so i can start with that first.Really need your help (5 Replies)
Discussion started by: GODBLESSME
5 Replies

7. Shell Programming and Scripting

system functions

Hi guys i wanna to buil small pro as calc to do many things for example clear memory specify a memory register and so on and quit using scripting language like perl or awk which command i use to deal with memory like m0 and how to clear or specify regester... (2 Replies)
Discussion started by: Ame
2 Replies

8. AIX

Need AIX system commands

Hey Guyz, I am preparing an inventory kindof thing about the aix servers.. I need help to find out the below details for many AIX servers.. Machine model and version Disk Size RAM size no. of CPUs and thier information list of softwares installed I searched in web.. but not much info I... (4 Replies)
Discussion started by: thariqueakbar
4 Replies

9. Solaris

rsh commands not getting executed from Solaris 10 System to AIX System

Hi Friends, I am trying to execute rsh commands from Solaris 10 system to AIX system. When I give; Solaris10# rsh <hostname> ls -l , it gives me an error rshd : 0826-826 The host name for your address is not known At the same time, Solaris10# rsh <hostname> ---- gives me remote shell of... (25 Replies)
Discussion started by: jumadhiya
25 Replies

10. AIX

commands to get system specs

Hi, I want to find some information regarding system specs such as CPU speed, total disk space, total RAM, network topology eg. ethernet, patch number, OS patches, database. Thanks (2 Replies)
Discussion started by: DarReNz
2 Replies
Login or Register to Ask a Question