You could either use a permanent magnet, AC synchronous motor -- which starts up in a random direction, and will self-reverse if blocked -- or alternatively you could use a simple mechanical coupling to produce a back-and-forth action from a continuous rotation (the latter method being employed in fans).