-2

Bash question!

so I have n arguments, and for each argument I'd like to to do a for loop and assign variables to hold characteristics of each argument. for example I have a script that runs in a continuous while loop and looks at user activity in my network... this is a simple outline of what my problems are:

while true

for argument
do 
# build an array to hold times
"$user"_times =()
# set a boolean value
"$user"_boolean=true

     if [ ""$user"_boolean" = true ]
     then
     echo $user logged on 
     "$user"_times+=( timestamp )
     fi
 done 
done
exit 0

the real script will look at user activity, update the boolean based on certain user behavior, and log some user activity info in the array- but I'm trying to get this to work so I can add the easy meat. what should the syntax be? I'm having a hard time making the variables work.

asia1028
  • 9
  • 1
  • 5
  • 1
    See [Bash FAQ 006](http://mywiki.wooledge.org/BashFAQ/006) for discussion about variable indirection in the shell. – Etan Reisner Jul 09 '15 at 02:07

1 Answers1

0

Since bash doesn't support hash/maps, I'd consider perl/python to store user activity against their hash id. You also have access to vectors for variable sized activity details, eg a hash of userid's containing a vector of activities.

Python script to list users and groups

Community
  • 1
  • 1
rupert160
  • 1,441
  • 1
  • 17
  • 19