Sponsored Content
Top Forums UNIX for Dummies Questions & Answers passing a variable inside a variable to a function Post 302158193 by KingVikram on Monday 14th of January 2008 05:37:00 PM
Old 01-14-2008
Question 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 [ $? -eq 1 ]
then
echo "line number:$var_cnt, message: field is not null"
fi
done
--------------
C1 has a value, as does C9

I need to pass values stored in C1 and C9 to the function

Any help would be highly appreciated.

Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing a variable name to be created within a function

Is it possible to pass a variable name, as a parameter to a function, so it can be created within this function ? Something like this: func_uppercase abcdefgh var_name where the 1st parameter is the string I want to convert and the 2nd is the desired variable name... $2=`echo "$1" |... (2 Replies)
Discussion started by: 435 Gavea
2 Replies

2. 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

3. 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

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 a variable inside another variable.

Any help would be great. I know this is a dumb way of doing this, but I would like to know if there is a solution doing it this way. I'm very new at this and I'd like to learn more. Thanks! :D:D count=0 while ; do echo "enter your name" read name_$count let count=count+1 done ... (2 Replies)
Discussion started by: reconflux
2 Replies

6. Shell Programming and Scripting

variable inside variable inside loop headache

Hi Gurus I have a file called /tmp/CMDB which looks like this serial: 0623AN1208 hostname: server1 model: x4100 assetID: 1234 I am writing a for loop that will go through this file line by line creating a variable of itself. Using the first iteration of the loop (i.e. the first line) as... (6 Replies)
Discussion started by: hcclnoodles
6 Replies

7. 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

8. Shell Programming and Scripting

Error during Accessing Global variable inside function

emailid=myemail@xyz.com taskName="DB-Backup" starttime=`date` email() { subject="$taskName" ": " $* " at `date` " mutt -s "$subject" $emailid < /dev/null } email "Starting" #do my stuff email "Finished" The above code gives following error ./dbbackup.sh: line 6: :... (5 Replies)
Discussion started by: nitiraj.rathore
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. UNIX for Beginners Questions & Answers

How to call variable inside a function globally?

Hi Gurus, Is there a way to call a variable inside a function anywhere within the script? Thanks. BR, Ernesto (2 Replies)
Discussion started by: ernesto
2 Replies
elf_errmsg(3ELF)					       ELF Library Functions						  elf_errmsg(3ELF)

NAME
elf_errmsg, elf_errno - error handling SYNOPSIS
cc [ flag ... ] file ... -lelf [ library ... ] #include <libelf.h> const char *elf_errmsg(int err); int elf_errno(void); DESCRIPTION
If an ELF library function fails, a program can call elf_errno() to retrieve the library's internal error number. As a side effect, this function resets the internal error number to 0, which indicates no error. The elf_errmsg() function takes an error number, err, and returns a null-terminated error message (with no trailing new-line) that describes the problem. A zero err retrieves a message for the most recent error. If no error has occurred, the return value is a null pointer (not a pointer to the null string). Using err of -1 also retrieves the most recent error, except it guarantees a non-null return value, even when no error has occurred. If no message is available for the given number, elf_errmsg() returns a pointer to an appropriate message. This function does not have the side effect of clearing the internal error number. EXAMPLES
Example 1 A sample program of calling the elf_errmsg() function. The following fragment clears the internal error number and checks it later for errors. Unless an error occurs after the first call to elf_errno(), the next call will return 0. (void)elf_errno(); /* processing ... */ while (more_to_do) { if ((err = elf_errno()) != 0) { /* print msg */ msg = elf_errmsg(err); } } ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Stable | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
elf(3ELF), libelf(3LIB), attributes(5) SunOS 5.11 11 Jul 2001 elf_errmsg(3ELF)
All times are GMT -4. The time now is 03:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy