try to free the ship by giving full astern (or full ahead) with successively the rudder to hard starboard and hard port (a lot depends on the type and size of ship)
call the assistance of tug boats
consider jettison of cargo (to throw cargo overboard). Be careful of risk of pollution