Turn off the water supply to the house, if the leaking pipe is a supply pipe. If the leaking pipe is the drain pipe, it is not necessary to cut off the water. If you are unsure of which type of pipe is leaking, turn off the main water supply to be safe.
Slide a stud finder across the wall on each side of the pipes and locate the wall studs. Mark the studs with a pencil. Trace a straight line down the wall at the center of each stud with a pencil. Measure one foot above the highest pipe and below the lowest pipe. Draw straight lines from the marks to each stud. This gives you enough room to work while limiting the amount of wall repair necessary once you replace the pipe.
Cut the trace line on the wall with a utility knife, if the wall is made of drywall without tile. If ceramic tile is on the wall, cut through it and the wall using a hand grinder with a diamond blade wheel. Remove the section of wall around the pipes.
Remove rust around the fittings on each end of the galvanized pipe you are replacing using a wire brush. The rust makes disconnecting the pipe difficult. Removing as much rust as possible with the wire brush enables turning of the fittings. Brush both ends of the fittings.
Cut a 6-inch section out of the center of the leaking galvanized pipe with the grinder and diamond wheel. Most galvanized pipe in the bathroom wall connect to elbows. Attempting to remove the pipe from elbows without cutting requires removing the pipe where the run first begins.
Hold the elbow fitting with a pipe wrench and place another pipe wrench on the galvanized pipe as close to the elbow as possible. Rotate the bad galvanized pipe counterclockwise while holding the elbow fitting steady. Remove the galvanized pipe from the fitting. Repeat for the other end of the faulty pipe.
Grab the good galvanized pipe with a pipe wrench, and rotate the elbow fitting counterclockwise with the second pipe wrench. Continue unthreading the elbow until it is off the pipe. Repeat for the opposite elbow fitting.
Clean the threads on the ends of each good galvanized pipe inside the wall with the wire brush. Apply pipe dope to the threads of the galvanized pipe with the applicator on the bottom of the can cap. Thread the threaded side of the slip adapter elbow to the end of the pipe. The slip adapter elbow has one end with female threads and the opposite end has no threads. Once hand tight, turn the elbow with a pair of slip joint pliers until the end is pointing to the opposite pipe. Repeat for the opposite pipe.
Measure between the two elbows with a tape measure. When measuring, measure from the inside of each elbow at the visible line. This is where the new CPVC or PVC pipe must seat when installing.
Cut the piece of CPVC or PVC pipe to the length necessary with a hacksaw. Sand the cut edge with fine-grit sandpaper to smooth the edge.
Fit the pipe into one elbow and bend the pipe slightly in the middle to insert the opposite end into the other elbow. This helps ensure that the pipe fits correctly before gluing. Once you determine the pipe is cut correctly, remove the pipe from the elbows.
Apply pipe primer to the inside of each elbow with the applicator that comes on the bottom of the can cap. Apply primer to the outside ends of the pipe, covering 4 inches of each end. Apply a film of pipe cement to the inside of the elbows and the outside of the pipe with the applicator that comes with the can.
Insert one end of the pipe into one elbow. It might require some twisting left to right to get the end of the pipe to seat all the way into the elbow. Bend the center of the pipe slightly to maneuver the opposite end into the other elbow. Twist the pipe left to right inside the elbow as necessary until both ends seat inside the elbow.
Measure from the bottom of the hole to the lowest pipe, and the width of the hole. Cut a piece of 1/2-inch thick drywall to the measurements with a utility knife. Repeat for the top of the hole to the highest pipe.
Secure the two pieces of drywall to the studs with drywall screws. This provides a way to remove the drywall in the event you must access the pipes again.
Turn on the main water supply to the house.