Sponsored Content
Top Forums Shell Programming and Scripting Passing a variable name to be created within a function Post 47189 by oombera on Wednesday 4th of February 2004 01:20:08 PM
Old 02-04-2004
Someone's bound to reply who knows how to do this and negate my answer... Smilie

... but in short I don't know how and can't imagine why you'd want to. Any reason inparticular you're trying to do this? If the first parameter is, for example, a name you're passing to the script, it seems alot easier to me to just script name="$1" and call it a day.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

passing variable to function

Hi, I am trying to sum up numbered columns and in order to tidy up the program I have wrote a function to do the adding of some numbers. I have a problem though with passing a variable to the function in the UNIX bash shell. The function only gives the first number in the variable list and does... (4 Replies)
Discussion started by: Knotty
4 Replies

2. UNIX for Advanced & Expert Users

Passing a unix variable value to a Plsql function

Suppose I have a unix variable called RGNM which is holding a value. Now I want to call a plsql function in my script. THis plsql function takes one IN parameter. I want to pass my UNIX VARIABLE Value to the plsql function. Can i just give it by giving $RGNM in the function after calling sqlplus... (1 Reply)
Discussion started by: cobroraj
1 Replies

3. UNIX for Dummies Questions & Answers

passing a variable inside a variable to a function

I would like to know how to pass a variable inside a variable to a function. sample code below -------------- for x in 1 9 do check_null $C$x ##call function to check if the value is null if then echo "line number:$var_cnt,... (2 Replies)
Discussion started by: KingVikram
2 Replies

4. Shell Programming and Scripting

Passing global variable to a function which is called by another function

Hi , I have three funcions f1, f2 and f3 . f1 calls f2 and f2 calls f3 . I have a global variable "period" which i want to pass to f3 . Can i pass the variable directly in the definition of f3 ? Pls help . sars (4 Replies)
Discussion started by: sars
4 Replies

5. Shell Programming and Scripting

passing variable content to a function

following on from below link https://www.unix.com/shell-programming-scripting/171076-shell-scripting.html#post302573569 i will be using file reading in while loop say for example while read line123 do echo "line read is $line123" insert_funct $line123 done< mysqldump.sql... (6 Replies)
Discussion started by: vivek d r
6 Replies

6. Programming

Created a wrapper for a function in a class.

I have a class called Parsing with the following function. I want to create a wrapper for it, so that I call it using GetReal rather than GetFloat. Bit confused on how to do this. class Parsing { private: int Length; // int Ptr; ... (3 Replies)
Discussion started by: kristinu
3 Replies

7. Shell Programming and Scripting

Passing alias to a function

The objective of this function is to validate the file full path. cat /dev/null > crontab_NOTEXISTS.txt function File_Existence # Accepts 1 parameter { file_name="$(echo $1)" echo "${file_name}" && break || echo "$file_name NOT FOUND" >> crontab_NOTEXISTS.txt } while read file_name... (7 Replies)
Discussion started by: aimy
7 Replies

8. UNIX for Advanced & Expert Users

Passing variable as input & storing output in other variable

I have a below syntax its working fine... var12=$(ps -ef | grep apache | awk '{print $2,$4}') Im getting expected output as below: printf "%b\n" "${VAR12}" dell 123 dell 456 dell 457 Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)
Discussion started by: sam@sam
5 Replies

9. Shell Programming and Scripting

Passing variable value in a function to be used by another function

Hello All, I would like to ask help from you on how to pass variable value from a function that has been called inside the function. I have created below and put the variables in " ". Is there another way I can do this? Thank you in advance. readtasklist() { while read -r mod ver... (1 Reply)
Discussion started by: aderamos12
1 Replies

10. Programming

Local variable in a C function is not getting created in stack when its compiled with GCC

Hi, I am working in UEFI EDK2 Bios source. We created a platform related new package in the EDK2 source. I find a strange issue with the platform related code we added. When I did source level debugging I noticed the local variable in a C function is not getting created in stack when its... (6 Replies)
Discussion started by: Divya R
6 Replies
getusershell(3) 					     Library Functions Manual						   getusershell(3)

NAME
getusershell, getusershell_r, setusershell, setusershell_r, endusershell, endusershell_r - Get the names of legal user shells LIBRARY
Standard C Library (libc.a) SYNOPSIS
char *getusershell(void); int setusershell(void); int endusershell(void); The following obsolete functions are supported in order to maintain backward compatibility with previous versions of the operating system. You should not use them in new designs. int getusershell_r( char *shell, int len unsigned int *state); int setusershell_r( unsigned int *state); int endusershell_r( unsigned int *state); PARAMETERS
Points to a buffer for the shell name. Specifies the length of the shell parameter. Points to a variable which stores information about the contents of the /etc/shells file. DESCRIPTION
The getusershell() function returns a pointer to a string that contains the name of a legal user shell as defined by the system manager in the /etc/shells file. If the /etc/shells file does not exist, the standard system shells are returned. On subsequent calls, the getusershell() function returns the next shell. The endusershell() function resets the list so that subsequent calls of getusershell() reread the list from /etc/shells. The setusershell() function rereads the list from /etc/shells and subsequent calls of getusershell() start from the beginning. NOTES
The getusershell() function returns a pointer to thread-specific data. Subsequent calls to the function from the same thread overwrite this data. The getusershell_r(), setusershell_r(), and endusershell_r() functions are obsolete reentrant versions of the getusershell(), setuser- shell(), and endusershell() functions. They are supported in order to maintain backward compatibility with previous versions of the oper- ating system and should not be used in new designs. Note that you must initialize the state parameter to 0 (zero) before its first access by any of these functions. RETURN VALUES
Upon successful completion, the getusershell() function returns a pointer to a character string. If it fails or reaches the end of the shell file, it returns a null pointer. Upon successful completion, the getusershell_r() function stores a pointer to the shell name in shell and returns a value of 0 (zero). Upon failure, it returns a value of -1 and places an appropriate value in the errno variable. Upon successful completion, the setusershell_r() function returns a value of 0 (zero). Upon failure, it returns a value of -1 and places an appropriate value in the errno variable. The endusershell_r() function always returns a value of 0 (zero). ERRORS
If any of the following conditions occurs, the getusershell_r() function sets errno to the corresponding value: Either the shell parameter is invalid, the len parameter is too small, or the state parameter is a null pointer. The end of the shell list has been reached (EOF). If the following condition occurs, the setusershell_r() function sets errno to the corresponding value: Unable to allocate memory for the reread list of shells. FILES
Contains the names of legal user shells. RELATED INFORMATION
Files: shells(4). delim off getusershell(3)
All times are GMT -4. The time now is 12:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy