building an array in sh on AIX
I have a script that works fin in Linux Specifically Red hat.
However when i go to run it in AIX it gets an error Not sure if this is an active forum or 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. |
Quote:
|
Sorry this is the whole script. I only forgot the #/bin/sh line.
#!/bin/sh |
Follow up in your DUPLICATE thread, thanks.
|
I sincerely apologizes for ruining your day and raising your blood pressure by my fopar in posting to this site wrongly.
Thank for your time. |
Your dup thread got closed. Please respond here to the questions I asked there...
|
The script needs bash. It only works with /bin/sh if /bin/sh is a link to bash.
|
Does it need bash because of the "+=" operator?
If yes, what would be the best syntax using ksh, or ksh93? If no, please ignore - looking for my rock to hide under :p |
Quote:
you should re-write the whole script no need to cat , awk will read the file just fine cut the output of awk? why not just get awk to process the input correctly? |
Quote:
Code:
outputarr=("${outputarr[@]}" ...) Code:
outputarr+=(...) |
Quote:
Code:
while IFS=":" read username pw uid guserprimarygroupid rest |
and that should work in other shells
no bashisms in it |
All times are GMT -5. The time now is 02:42 AM. |