South Africa moved within five wickets of victory in the first Test against Bangladesh at the Wanderers after bad light brought day four to an early close.