In this paper a methodology for designing and implementing a real time optimizing controller for nonlinear batch processes is discussed. The controller is used to optimize the system input and state trajectories according to a cost function. An interior point method with penalty function is used to incorporate constraints into a modified cost functional, and a Lyapunov based extremum seeking approach is used to compute the trajectory parameters. This technique was previously proposed for optimizing differentially flat systems in a cascade implementation. Smooth trajectories were generated with reduced computing time compared to many optimizations in literature. In this paper the theory is extended to general non-flat nonlinear systems in a true on-line optimization.