In general, you can use ls -sl for getting the names of currently selected nodes. To get shape node names only, you can use ls -s.
You can also use the listRelatives command to get the names of all the shape nodes that are hierarchically below (that is, child nodes) the currently selected nodes. For example:
string obj[]= `ls -sl`; listRelatives -s $obj[0];