There is a train line that starts at Malcha in Jerusalem, continues to Beit Shemesh, and then continues to Tel Aviv. You can change trains in Tel Aviv and go all the way up north.
The schedule is here. However, this scenic hilly route is extremely slow until Beit Shemesh, and a faster alternative is to drive to Beit Shemesh and take the train from there to Tel Aviv and all other destinations.
You can also catch a minyan on some of these trains.