LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-27-2005, 04:16 AM   #1
bahadur
Member
 
Registered: Apr 2004
Distribution: Linux Red Hat
Posts: 141

Rep: Reputation: 15
accessing variables inside a function


#!/bin/bash

extractor()
{
FILES=`ls -l |awk '/^-/ {print $9}'`
SUBDIR=`ls -l |awk '/^d/ {print $9}'`
}

looper()
{
for FIL in $FILES
do
permissions.sh $FIL $3
done

for DIR in $SUBDIR
do
echo " the permissions being passed to other script are $2"
permissions.sh $DIR $2
search.sh $DIR $2
done
}



echo " Processing the directory $1"
cd "$1"

extractor
looper
--------------------------------------------------------------------------------------------------------------------

when i try to pass the $3 in the looper function it is not able to acces the variable $3 .

why cant that function access that variable?
 
Old 03-27-2005, 04:41 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
afaik the $3 would be the third parameter passed to that specific function. why not save $3 as a sane variable when the script starts? $perms=$3 etc...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Defining a non-inline function inside class definition (tm) Programming 6 05-11-2005 09:14 AM
May I use variables inside /etc/sysconfig/iptables file?...how? leo Linux - Security 2 09-24-2004 09:26 PM
problem on dynamic function call inside a class! antony_csf Programming 0 06-29-2004 10:15 PM
accessing system variables in c++ gearoid Programming 4 05-13-2004 05:55 AM
Static Variables in C function swifty99uk Programming 4 04-14-2004 10:50 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration