Once you get familiarized with MEL scripting, you will inevitably want to traverse the complex nodes structure that Maya sets up for each object.  Just to quickly summarize the node system, all primitives have a ‘transform,’ ‘shape,’ ‘make,’ material node, and possibly some other nodes.  When you call for the name of an object, you are actually only accessing the base ‘transform’ object.  If you want more information or attributes, you’ll need to traverse the node system to access the others.  I go over this more in depth in my book YSYT somewhere in chapter 7 or 8 (I think), and also in 12.

To query the name of a Shape or Make node, use a combination of the commands listHistory, listConnections, and/or listRelatives from the transform node name string.  Use backticks to encapsulate the commands to return the connected names, and you may need to go a few levels down.  A good example of this is my function for getting an existing material on an object.  (note, getting a material, moves passed the Make and Shape nodes, but it’s still a good example.)

string $Name = "nurbsSphere1"; 
string $FF[] = `listRelatives $Name`;
string $GG[] = `listConnections $FF[0]`;
string $HH[] = `listConnections $GG[0]`;

The zeroth member of each $FF and $GG array is the lead string for that level.  So you may need to print the contents of these arrays and you’ll find the pattern leading to the Make or Shape node.  In most cases it will be the first (second index) from the listed Relatives, or listed Connections.

Some things to remember:
Every release of Maya is different, so test your indexes prior to hard-coding.  You may need to shift some index numbers, but the listRelatives and listConnections should be in the right configuration.  To get the material shader, you’ll need to make a distinction between objects with the initial material and objects with a substituted material.    Then it will be stored in the final array ($HH in the example above).  Maya 5 through 6.5 is the third index, whereas newer versions have it stored at the 4 or 5 spot.  If you want to make a robust function, you can always use the “version” command set up a conditional case programming structure.