If you are replicating MSDB database, the agent jobs would get automatically ported. Assuming that is not the case, I don't know of a T-SQL way of generating all the scripts in one shot. Might be possible using Powershell/SMO. Googling for it, I see examples - here is one. I have not tried it. http://www.johnsansom.com/script-sql-server-agent-jobs-using-powershell/
I would rather like to have further explanation of the term "a script to script out all the SQL Server agent jobs and automate it". SQL agent is used to Automate a task/job e.g. pick all the changes happened in tableA of ServerA and push them into tableA of ServerB. With that, what do you actually want to perform via a script which again automate agent jobs???