Executing scripts using more users Executing scripts using more users bash bash

Executing scripts using more users


  • Make a fork (using '&') for user_1 and for user_2. They should communicate (similar as client-serwer) using 'lock file' (semaphore). For example user_1 doing something and user_2 checking is 'lock file' exist in while ...sleep loop

  • Maybe that is stupid, but you can use ssh user@localhost end keys


If you happen to have zsh, I think you can do this easily - something like:

#!/bin/zshcoproc user1_scriptsu user2do_stuffecho "your_turn" >&pread MY_TURNdo_more_stuffecho "your_turn" >&pread MY_TURN...

user1_script:

#!/bin/zshread MY_TURNdo_stuffecho your_turnread MY_TURNdo_more_stuff...

If you're stuck, and have zsh, it's worth a try anyway.


You could run as root. Sounds risky? Not if you are careful and precede each command with su and add the username like so:

su -c 'script1' user_1 && su -c 'script2' user_2

This will (assuming you start as root) change the user to user_1 before running script1 then back to root then change to user_2 to run script2.. all without asking for multiple passwords.