Although you probably know this, I'll say it anyway - this script is only necessary if you are using forward kinematics on the joints. If you are using IK, it ignores the orientation of the joints.
If you are using the script as you printed it here, the word "joint" should not be plural. Also, you need to select ALL the joints you want to affect, not just the top of the hierarchy - you can do this two ways:
One way is to select the top of the hierarchy and type "select -hi". This selects all the descendant joints from that one. Then type "joint -e -oj xyz -zso" (the zso is a neatness thing - it orients the zero scale orientation to match the rotation orientation, it's usually not necessary).
Otherwise, select the top of the hierarchy and type "joint -e -oj xyz -zso -ch". The "-ch" applies the command to the child joints of that hierarchy.
You're not done yet -
If you are doing an FK animation, merely orienting the X axis down the descendant joint is not enough - you have to orient the Y-axes to point the same way if you want your numeric joint rotation to follow accurately.
In component mode, select the joints and click on the "?" icon in the selection masks array. This will display your joint orientations. You'll see that some of them are just flipped 180 degrees (Maya orients the Y axis of these joints toward the inside of the curvature of the joint as drawn). select these and type "rotate -r 180 0 0". This will flip them to the correct orientation. Those that are off by more or less than 180 degrees, or those you want to manually set to a different axis, you'll have to select and rotate into position manually.
Good luck