How to call elgg functions in php scripts?

Hello Gurus !

I'm a newbie here... I wrote a testing php script-file of 

function get_user_by_username($username) { return _elgg_services()->usersTable->getByUsername($username);}

echo  get_user_by_username("drleos")."\n";

When running the file as php -f <script-file>, I get "PHP Fatal error:  Call to undefined function _elgg_services() in <script-file> on line 10".  But the "_elgg_services" function is used in various files under elgg/mod/.

How should I know that function known to php? Please advise kindly...