A pneumatic cylinder will only allow positioning against a stop, either the stroke of the cylinder, or a set of hard stops. If there are intermediate positions, hydraulic cylinder would be required. For the cylinder you would need a hydraulic power unit, piping and some sort of control system. For the gear rack, infinite positioning is possible. This would require some sort of drive arrangement (assumed electric motor and gear reducer) and a control system.