<p>In other words:</p>

<ol>
<li>Log on as Bert (who is an administrator)</li>
<li>Using fast user switching, log on as Ernie (Bert remains logged on)</li>
<li>Switch back to Bert</li>
<li>Bert logs Ernie off</li>
</ol>

<p>What is the best way to achieve step 4?</p>

[{'answer_id': 79280, 'author': 'andrewdotnich', 'author_id': 10569, 'author_profile': 'https://Stackoverflow.com/users/10569', 'pm_score': 2, 'selected': False, 'text': '<p><a href="http://macosx.com/tech-support/mac/force-shutdown-logoff-restart-via-applescript/25909.html" rel="nofollow noreferrer">This forum post</a> has a bash script for OSX that should do the trick. It takes a username as an argument and logs off that user.</p>\n\n<p>I\'ve not tried it, so your mileage may vary. But it looks like it suits your needs.\nWhat exactly are you trying to achieve?</p>\n'}, {'answer_id': 42917620, 'author': 'Babak', 'author_id': 4676, 'author_profile': 'https://Stackoverflow.com/users/4676', 'pm_score': 3, 'selected': True, 'text': "<p><code>sudo launchctl bootout user/$(id -u &lt;username&gt;)</code></p>\n\n<p>Replace <code>&lt;username&gt;</code> with the target user's user name.</p>\n"}]
['https://Stackoverflow.com/questions/79133', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4676/']