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?
10 More Discussions You Might Find Interesting
1. Programming
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
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 Advanced & Expert Users
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
4. Infrastructure Monitoring
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
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
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
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
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
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
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