After trying for a quite while, I eventually found that in order to get any result from running "rostopic list | grep ‘/counter’’’, I have to execute my program in another Webshell and don’t kill it. But it didn’t say anything about this in the notebook.
Maybe they should revise it?