Do plants use only solar energy or can they get energy from other forms of light?

Plants use energy from sun. Is it just sun's light energy or any form of light (like light from a tube light) can excite electrons and initiate photosynthesis.

This actually sounds a bit idiotic but in Campbell Biology 10th ed. there is a line in Ch 4. "Plants use solar energy to convert atmospheric CO2 to molecules of life… "

If it is due to sun, then how does plant know which light is from sun and which is not?

As per @anongoodnurse comment:

Plants use any light of the proper wavelengths. Typically the available light to plants is the sun but if you place a plant indoor under a fair amount of light bulbs that produce light at similar wavelength that the sun, there is no reason for the plant to even notice the light is different that the sun light and the plant will grow just normally.