Sponsored Content
Top Forums Shell Programming and Scripting How to execute functions or initiate functions as command line parameters for below requirement? Post 302762217 by posix on Monday 28th of January 2013 08:53:40 AM
Old 01-28-2013
How to initiate the function Smilie, check how simple functions should work for your choosen inputs
Code:
#!/bin/sh
fun1(){
echo " i am in fun-1"
}
fun2(){
echo " i am in fun-2"
}
fun3(){
echo " i am in fun-3"
}
echo "please input your value"
read var
case $var in
1)fun1;;
2)fun2;;
3)fun3;;
*)echo "pleaes input the correct values"
esac

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passing command line parameters to functions - sh

All, I have a sh script of the following tune: function a () { #functionality.. } function b () { #functionnlity.. } function check () { # this function checks for env and if all fine call build } function usage () { #sh usage details } function build () { #calls either a or b or... (5 Replies)
Discussion started by: vino
5 Replies

2. Shell Programming and Scripting

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... (6 Replies)
Discussion started by: Raom
6 Replies

3. Shell Programming and Scripting

Get the List of functions with modified parameters

Hi I have 2 files a.c and a.bak where I changed long to int using awk script. I want to get the list of functions whose parameters got modified for eg: fun ( long a, long b ) might be changed to fun ( int a, int b ) (1 Reply)
Discussion started by: Sivaswami
1 Replies

4. Shell Programming and Scripting

CSH: Concatenating Strings, how to add new line character and functions?

Hello, I'm trying to run a program on a directory (traverse sub dirs too) through my csh script. Arrays support in CSH is appalling, something like associative arrays would have helped me do this so much easier. Anyway, I want to hold some details extracted from the program and then at the... (0 Replies)
Discussion started by: ragabonds
0 Replies

5. Shell Programming and Scripting

Handling parameters in Shell Functions

Hi, Please help me with the below situation where I have to handle the parameters passed to a function in a unique way. Below is the code, which I am trying to execute. I basically want to pass the parameter to a function, where I am trying to get user input into array(s). I want to name... (7 Replies)
Discussion started by: bharath.gct
7 Replies

6. Shell Programming and Scripting

howto place in one line output from two functions

Hi I would like to place in one line output from two functions. Both functions return text with print cmd. When I place above code in script it will place them in series. e.g. 1 #/bin/ksh 2 3 function1() 4 { 5 print "My name is" 6 ... (3 Replies)
Discussion started by: presul
3 Replies

7. Shell Programming and Scripting

Help in retrieving the ending line numbers of the functions

Hi! I've a C file which consist of many function definitions with numbers at the beginning as shown below.. 10 void search() 11 { 12 /*body 14 * 15 * 17 * 18 * 40 * 42 * 60 } 90 void func_name() 95 { 99 /*body 100 * 105 * 111 * (7 Replies)
Discussion started by: abk07
7 Replies

8. Shell Programming and Scripting

Pass parameters to a function and running functions in parallel

Hi , I have a script which is using a text file as I/P. I want a code where it reads n lines from this file and pass the parameters to a function and now this script should run in such a way where a function can be called in parallel with different parameters. Please find below my script, it... (1 Reply)
Discussion started by: Ravindra Swan
1 Replies

9. Shell Programming and Scripting

Python passing multiple parameters to functions

Hi, I am a beginner in python programming. In my python script have a main function which calls several other functions. The main function gets its input by reading lines from a input text file. I call the main function for every line in input text file through a loop. def main(line): var1... (6 Replies)
Discussion started by: ctrld
6 Replies
funref(3)							SAORD Documentation							 funref(3)

NAME
FunRef - the Funtools Reference Handle SYNOPSIS
A description of how to use a Funtools reference handle to connect a Funtools input file to an output file. DESCRIPTION
The Funtools reference handle connects a Funtools input file to a Funtools output file so that parameters (or even whole extensions) can be copied from the one to the other. To make the connection, the Funtools handle of the input file is passed to the final argument of the FunOpen() call for the output file: if( !(ifun = FunOpen(argv[1], "r", NULL)) ) gerror(stderr, "could not FunOpen input file: %s ", argv[1]); if( !(ofun = FunOpen(argv[2], "w", ifun)) ) gerror(stderr, "could not FunOpen output file: %s ", argv[2]); It does not matter what type of input or output file (or extension) is opened, or whether they are the same type. When the output image or binary table is written using FunImagePut() or FunTableRowPut() an appropriate header will be written first, with parameters copied from the input extension. Of course, invalid parameters will be removed first, e.g., if the input is a binary table and the output is an image, then binary table parameters such as TFORM, TUNIT, etc. parameters will not be copied to the output. Use of a reference handle also allows default values to be passed to FunImagePut() in order to write out an output image with the same dimensions and data type as the input image. To use the defaults from the input, a value of 0 is entered for dim1, dim2, and bitpix. For example: fun = FunOpen(argv[1], "r", NULL); fun2 = FunOpen(argv[2], "w", fun); buf = FunImageGet(fun, NULL, NULL); ... process image data ... FunImagePut(fun2, buf, 0, 0, 0, NULL); Of course, you often want to get information about the data type and dimensions of the image for processing. The above code is equivalent to the following: fun = FunOpen(argv[1], "r", NULL); fun2 = FunOpen(argv[2], "w", fun); buf = FunImageGet(fun, NULL, NULL); FunInfoGet(fun, FUN_SECT_DIM1, &dim1, FUN_SECT_DIM2, &dim2, FUN_SECT_BITPIX, &bitpix, 0); ... process image data ... FunImagePut(fun2, buf, dim1, dim2, bitpix, NULL); It is possible to change the reference handle for a given output Funtools handle using the FunInfoPut() routine: /* make the new extension the reference handle for the output file */ FunInfoPut(fun2, FUN_IFUN, &fun, 0); When this is done, Funtools specially resets the output file to start a new output extension, which is connected to the new input reference handle. You can use this mechanism to process multiple input extensions into a single output file, by successively opening the former and setting the reference handle for the latter. For example: /* open a new output FITS file */ if( !(fun2 = FunOpen(argv[2], "w", NULL)) ) gerror(stderr, "could not FunOpen output file: %s ", argv[2]); /* process each input extension in turn */ for(ext=0; ;ext++){ /* get new extension name */ sprintf(tbuf, "%s[%d]", argv[1], ext); /* open it -- if we cannot open it, we are done */ if( !(fun=FunOpen(tbuf, "r", NULL)) ) break; /* make the new extension the reference handle for the output file */ FunInfoPut(fun2, FUN_IFUN, &fun, 0); ... process ... /* flush output extension (write padding, etc.) */ FunFlush(fun2, NULL); /* close the input extension */ FunClose(fun); } In this example, the output file is opened first. Then each successive input extension is opened, and the output reference handle is set to the newly opened input handle. After data processing is performed, the output extension is flushed and the input extension is closed, in preparation for the next input extension. Finally, a reference handle can be used to copy other extensions from the input file to the output file. Copy of other extensions is con- trolled by adding a "C" or "c" to the mode string of the FunOpen() call of the input reference file. If "C" is specified, then other extensions are always copied (i.e., copy is forced by the application). If "c" is used, then other extensions are copied if the user requests copying by adding a plus sign "+" to the extension name in the bracket specification. For example, the funtable program utilizes user-specified "c" mode so that the second example below will copy all extensions: # copy only the EVENTS extension csh> funtable "test.ev[EVENTS,circle(512,512,10)]" foo.ev # copy ALL extensions csh> funtable "test.ev[EVENTS+,circle(512,512,10)]" foo.ev When extension copy is specified in the input file, the call to FunOpen() on the input file delays the actual file open until the output file also is opened (or until I/O is performed on the input file, which ever happens first). Then, when the output file is opened, the input file is also opened and input extensions are copied to the output file, up to the specific extension being opened. Processing of input and output extensions then proceed. When extension processing is complete, the remaining extensions need to be copied from input to output. This can be done explicitly, using the FunFlush() call with the "copy=remaining" plist: FunFlush(fun, "copy=remaining"); Alternatively, this will happen automatically, if the output file is closed before the input file: /* we could explicitly flush remaining extensions that need copying */ /* FunFlush(fun2, "copy=remaining"); */ /* but if we close output before input, end flush is done automatically */ FunClose(fun2); FunClose(fun); SEE ALSO
See funtools(7) for a list of Funtools help pages version 1.4.2 January 2, 2008 funref(3)
All times are GMT -4. The time now is 03:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy