LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Closed Thread
  Search this Thread
Old 08-13-2019, 01:34 PM   #1
unix1adm
Member
 
Registered: Oct 2008
Posts: 688

Rep: Reputation: 32
having trouble building an array in AIX. Works in Linux


I have a script that works fine in Linux Specifically Red hat.

However when i go to run it in AIX it gets an error

Not sure if the correct place to put this question.

Any help is appreciated.



# Retrieve and format the system date/time appropriately
datetime=$(date "+%D %r")

# Enumerate users and non-empty groups on the system
for username in $(cat /etc/passwd | awk '/^#/{next}1' | cut -d: -f1); do
# Search for users in primary groups and append to array
userprimarygroupid=$(grep ^$username /etc/passwd | awk '/^#/{next}1' | cut -d: -f4)
userprimarygroupname=$(grep ":$userprimarygroupid:" /etc/group | awk '/^#/{next}1' | cut -d: -f1)
outputarr+=( ""$userprimarygroupname"",""$username"",""Local User"",""$datetime"")
# Search for users in secondary groups and append to array
for usersecondarygroupname in $(grep $username /etc/group | cut -d: -f1); do
outputarr+=( ""$usersecondarygroupname"",""$username"",""Local User"",""$datetime"")
done
done

# Write Results to stdout for mgmt systems to retrieve
printf '%s\n' "${outputarr[@]}" | sort -u


---------------------

error

./localgroup.sh[6]: 0403-057 Syntax error at line 10 : `(' is not expected.
 
Old 08-13-2019, 01:39 PM   #2
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,769

Rep: Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260
Please use [code] tags when posting code. It makes it much more readable.

Please tell us which line is line 10 of the script. Maybe highlight it?
If it's this line
Code:
for username in $(cat /etc/passwd | awk '/^#/{next}1' | cut -d: -f1); do
I believe the $(command) construct is a bash-ism.

What shell is being used on the RH machine?
What shell on the Unix box?

Last edited by scasey; 08-13-2019 at 01:42 PM.
 
Old 08-13-2019, 01:52 PM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 21,935

Rep: Reputation: 5803Reputation: 5803Reputation: 5803Reputation: 5803Reputation: 5803Reputation: 5803Reputation: 5803Reputation: 5803Reputation: 5803Reputation: 5803Reputation: 5803
Asked this in the OP's duplicate thread: https://www.linuxquestions.org/quest...ix-4175659081/

OP has also been asked several times over the past ELEVEN YEARS, to use code tags, and not post duplicates.

Reported

Last edited by TB0ne; 08-13-2019 at 01:54 PM.
 
Old 08-13-2019, 02:03 PM   #4
unix1adm
Member
 
Registered: Oct 2008
Posts: 688

Original Poster
Rep: Reputation: 32
My apologies for the code tags I was entering this in a hurry. The other forum look dead. No posts in a long time so I thought I would try here.

Would yo be so kind as to point me to a link that shows me how to use code tags in this forum.

Last edited by unix1adm; 08-13-2019 at 02:07 PM.
 
Old 08-13-2019, 02:10 PM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 21,935

Rep: Reputation: 5803Reputation: 5803Reputation: 5803Reputation: 5803Reputation: 5803Reputation: 5803Reputation: 5803Reputation: 5803Reputation: 5803Reputation: 5803Reputation: 5803
Quote:
Originally Posted by unix1adm View Post
My apologies for the code tags I was entering this in a hurry. The other forum look dead. No posts in a long time so I thought I would try here.

Would yo be so kind as to point me to a link that shows me how to use code tags in this forum.
You've been here ELEVEN YEARS, and never used CODE tags, despite being asked, so the 'in a hurry' response kind of falls flat, especially since you've used it before.
https://www.linuxquestions.org/quest...5/#post5852069

And the LQ Rules are very clear about posting duplicates as well. There are icons on the posting window...did you try putting your mouse over them, and looking at the tool-tips? Specifically the # character???

Last edited by TB0ne; 08-13-2019 at 02:13 PM.
 
Old 08-13-2019, 02:18 PM   #6
unix1adm
Member
 
Registered: Oct 2008
Posts: 688

Original Poster
Rep: Reputation: 32
I sincerely apologize and did not mean to raise anyone's blood pressure over this. i have not been posting for some time

I will gladly close this duplicate out.

As I said the other forum had no posts for over 100 days and I was not sure which forum to post under.
Thank you fro your kind words of advice
 
Old 08-13-2019, 02:23 PM   #7
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,769

Rep: Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260
Quote:
Originally Posted by unix1adm View Post
My apologies for the code tags I was entering this in a hurry. The other forum look dead. No posts in a long time so I thought I would try here.

Would yo be so kind as to point me to a link that shows me how to use code tags in this forum.
Sure. There's a link at the bottom of every page: "BB code"
If you hover your mouse over the tools at the top of the posting window, you'll find the one that says "Wrap [CODE] tags around selected text"


Now will you answer the questions in #2?
 
1 members found this post helpful.
Old 08-13-2019, 03:47 PM   #8
onebuck
Moderator
 
Registered: Jan 2005
Location: Summer Midwest USA, Central Illinois, Winter Central Florida
Distribution: SlackwareŽ
Posts: 13,429
Blog Entries: 31

Rep: Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602
Moderator Response

Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate of https://www.linuxquestions.org/quest...ix-4175659081/
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] building an array in sh on AIX unix1adm AIX 11 08-31-2019 10:11 AM
BASH-Adding array element: Naming issue using array[${#array[*]}]=5 calvarado777 Programming 8 07-26-2013 09:48 PM
newbie having trouble with posting my result from an array ashevillan Linux - Software 3 05-12-2013 05:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:52 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