LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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


Closed Thread
  Search this Thread
Old 06-19-2015, 12:15 PM   #1
Cpare
Member
 
Registered: Aug 2001
Location: Magic City, USA
Distribution: Ubuntu
Posts: 73

Rep: Reputation: 15
ksh shell script array question


--Crosspost from AIX for visibility--
The script below is failing with the addition of ${arrUsers[i]} to the echo line, if I change this to ${arrUsers[1]} it works, but I need the variable - I also tried ${arrUsers[$i]} without success. This worked in a prior script I wrote, but it may have been an older version of AIX - is there a new/better approach?

For those that will ask - this tool will search through directories to find content owned by users that are scheduled to have their AIX account removed, chowning the item (directory / folder) to a generic ID and make the file available to all users in a group.

Code:
#!/usr/bin/ksh

set -A arrFolders /dir2 /dir1
set -A arrUsers User1 User2

############################################################################

if [ "$1" = "" ]
then
   echo USAGE:
   echo "   usercleanup.sh OldUser"
else
        # Loop through each RootFolder
        for i in ${arrFolders[@]}
        do
                echo "Searching $i for $1 and chowning to ${arrUsers[i]}"
                #find . -user $1 \( -exec echo {} \; -o -exec true \; \) -exec grep banana {} \;
                #find $i -user $1 -exec chown ${arrUsers[i]} {} \; -exec chmod 766{} \;

        done
fi
 
Old 06-19-2015, 12:17 PM   #2
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,651

Rep: Reputation: 660Reputation: 660Reputation: 660Reputation: 660Reputation: 660Reputation: 660
Please don't cross post have patience
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] ksh unset on first element of associative array unsets the whole array luvshines Programming 4 05-29-2015 08:27 AM
[SOLVED] ksh shell script SharonGe Linux - Newbie 4 10-29-2010 01:12 AM
[SOLVED] shell script help: copying directory list into an array and then accessing the array richman1234 Linux - Newbie 6 07-26-2010 12:19 AM
Array shell script pooppp Linux - Networking 6 08-01-2008 09:37 AM
Shell Script that misbehaves under Linux but works in HP UX well... ksh environ. sammathew Linux - Software 7 09-17-2003 09:42 PM

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

All times are GMT -5. The time now is 01:45 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration