Function call not return value into var


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Function call not return value into var
# 1  
Old 04-18-2008
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 '{print $9;}'`
do
if [[ -d $zont ]]
then
count=1
fi
done
cd ..
return $count
}

When I call it from another function, the debug telling me that the function return value=1 but I can not see it in my varieable while I write like this:

ta=`Has_Subfolders $1`
echo $ta

Can please someone explain me why?
# 2  
Old 04-18-2008
Don't double post.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

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

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

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

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

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

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

8. UNIX for Advanced & Expert Users

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

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

10. 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
Login or Register to Ask a Question