Sponsored Content
Top Forums UNIX for Advanced & Expert Users Function call not return value into var Post 302187026 by jim mcnamara on Friday 18th of April 2008 09:30:18 PM
Old 04-18-2008
functions return a status code

use echo $? to see the value.

In general when you need a function to return something do it like this

Code:
#!/bin/ksh
foo()
{
       echo $(( $1 + 13 ))
}

value=$( foo 8)
echo $value

 

10 More Discussions You Might Find Interesting

1. Programming

Help with a function call

Hi, Can anyone help me figure out the problem I'm having with a function call? I have a header file, which sets an enum: typedef enum {INFO, WARNING, FATAL} Levels; int log_event (Levels, char *fmt, ...); ..then the function is called this way: log_event(INFO, "Message text"); ... (6 Replies)
Discussion started by: Stevhp
6 Replies

2. Solaris

/var/cron/log Return Codes

I want to know if there is any documentation or any type of information that can give a list of all of the return codes that can be seen in the /var/cron/log. I have seen a couple in my log file. Example: rc=1 and rc=64. (2 Replies)
Discussion started by: sjames
2 Replies

3. UNIX for Dummies Questions & Answers

Function call not return value into var

hi friends, I writing a script, one of the function there is: ################################### ########### Return 1 if has subfolders and 0 otherwise ################## # Get one Argument - Folder name Has_Subfolders() { count=0 cd $1 for zont in `ls -l | grep drw | awk... (1 Reply)
Discussion started by: katzs500
1 Replies

4. Infrastructure Monitoring

diffrence between method call and function call in perl

Hello, I have a problem with package and name space. require "/Mehran/DSGateEngineLib/general.pl"; use strict; sub System_Status_Main_Service_Status_Intrusion_Prevention { my %idpstatus; my @result; &General_ReadHash("/var/dsg/idp/settings",\%idpstatus); #print... (4 Replies)
Discussion started by: Zaxon
4 Replies

5. Shell Programming and Scripting

Return a value from called function to the calling function

I have two scripts. script1.sh looks -------------------------------- #!/bin/bash display() { echo "Welcome to Unix" } display ----------------------------- Script2.sh #!/bin/bash sh script1.sh //simply calling script1.sh ------------------------------ (1 Reply)
Discussion started by: mvictorvijayan
1 Replies

6. Shell Programming and Scripting

After exit from function it should not call other function

Below is my script that is function properly per my conditions but I am facing one problem here that is when one function fails then Iy should not check other functions but it calls the other function too So anyone can help me how could i achieve this? iNOUT i AM GIVING TO THE... (1 Reply)
Discussion started by: rohit22hamirpur
1 Replies

7. Shell Programming and Scripting

awk - sub() function and NR==var

Why does this work: awk 'NR==3 sub(FS $NF,x)' inputfile But not this: var=3 awk -v i=$var 'NR==i sub(FS $NF,x)' inputfile How would you do the same thing as the first line of code, but with a variable? (2 Replies)
Discussion started by: locoroco
2 Replies

8. Shell Programming and Scripting

Shell Scripting Function call return value

Hi I have a function : Make_Report() { trx_report=`sqlplus -s $conn_str << @@ set echo off; set pages 0; set feedback off; set verify off; select srv_trx_s_no,... (1 Reply)
Discussion started by: neeraj617
1 Replies

9. Shell Programming and Scripting

Return: can only `return' from a function or sourced script

Not sure where the problem is. I can run the script without any issue using the following command. . /opt/app/scripts/cdc_migration.sh But it fails with the below error when I try it this way /opt/app/scripts/cdc_migration.sh /opt/app/scripts/cdc_migration.sh: line 65: return: can only... (1 Reply)
Discussion started by: svajhala
1 Replies

10. Shell Programming and Scripting

Function - Make your function return an exit status

Hi All, Good Day, seeking for your assistance on how to not perform my 2nd, 3rd,4th etc.. function if my 1st function is in else condition. #Body function1() { if then echo "exist" else echo "not exist" } #if not exist in function1 my all other function will not proceed.... (4 Replies)
Discussion started by: meister29
4 Replies
ELF_GETSCN(3)						   BSD Library Functions Manual 					     ELF_GETSCN(3)

NAME
elf_getscn, elf_ndxscn, elf_newscn, elf_nextscn -- get/allocate section information for an ELF object LIBRARY
ELF Access Library (libelf, -lelf) SYNOPSIS
#include <libelf.h> Elf_Scn * elf_getscn(Elf *elf, size_t index); size_t elf_ndxscn(Elf_Scn *scn); Elf_Scn * elf_newscn(Elf *elf); Elf_Scn * elf_nextscn(Elf *elf, Elf_Scn *scn); DESCRIPTION
These functions are used to iterate through the sections associated with an ELF descriptor. Function elf_getscn() will return a section descriptor for the section at index index in the object denoted by ELF descriptor elf. An error will be signalled if the specified section does not exist. Function elf_ndxscn() returns the section table index associated with section descriptor scn. Function elf_newscn() creates a new section and appends it to the list of sections associated with descriptor elf. The library will automat- ically increment the e_shnum field of the ELF header associated with descriptor elf, and will set the ELF_F_DIRTY flag on the returned sec- tion descriptor. For ELF descriptors opened for writing, the ELF library will automatically create an empty section at index zero (SHN_UNDEF) on the first call to elf_newscn(). Function elf_nextscn() takes a section descriptor scn and returns a pointer to the section descriptor at the next higher index. Argument scn is allowed to be NULL, in which case this function will return a pointer to the section descriptor at index 1. If no further sections are present, function elf_nextscn() will return a NULL pointer. RETURN VALUES
Functions elf_getscn(), elf_newscn() and elf_nextscn() return a valid pointer to a section descriptor if successful, or NULL if an error occurs. Function elf_ndxscn() returns a valid section table index if successful, or SHN_UNDEF if an error occurs. ERRORS
These functions may fail with the following errors: [ELF_E_ARGUMENT] Arguments elf or scn were NULL. [ELF_E_ARGUMENT] Argument index exceeded the current number of sections in the ELF object. [ELF_E_ARGUMENT] Argument elf was not a descriptor for an ELF file. [ELF_E_ARGUMENT] Section descriptor scn was not associated with ELF descriptor elf. [ELF_E_CLASS] Descriptor elf was of an unknown ELF class. [ELF_E_SECTION] Argument elf specified extended section numbering in the ELF header with the section header at index SHN_UNDEF not being of type SHT_NULL. SEE ALSO
elf(3), elf_flagdata(3), elf_flagscn(3), elf_getdata(3), elf_getshdr(3), gelf(3) BSD
October 22, 2007 BSD
All times are GMT -4. The time now is 07:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy