I am running a script through root which will do login to all the registered users and will execute few commands(example: list down all the folders in users directory), collect their reports and copy it in root login.
My command looks like this
for i in `cat userlist`; do echo $i; su $i ; ls ; exit; done > folderList
The problem with this command is after doing a su to user it changes the shell and the script waits till it receives a exit from that shell