You run it from the router how?
Util::exec() uses "/system script run". If you're using f.e. scheduler, or /import a file, that's different.
Also, Util::exec() prepends the current menu, while Script::prepare() doesn't (since it has no notion of a menu). If your script says "ping" rather than "/ping" or "/tool ping", you may be running it from the wrong menu. With Script::prepare(), you're definitely running it from root.
Are there any errors on the PHP side, or does the script work without errors, it's just that you don't see any results from the ping? If the former - what is the error? If the latter... Maybe try to write the results to a global variable, and check the global variable afterwards?
I run it on router opening the script and clicking "run". To be honest, I tried to run the script I sent with ::prepare from browser with PHP and didn't succeed, and as I am against the clock, I used the util->exec instead. But if you know how I can run the script that I previously sent using ::prepare, any help is very appreciated. I tried several combinations of setCommand, request, setArgument (passing the name of the script) and nothing, no error, and no script running in that way.
About your second question: my script uses /tool ping, as you can see here:
:global pingPPPoE do={
:return [/tool ping $1 src-address=$2 count=$3];
}
It receives the following parameters:
$1 = ping destination
$2 = ping origin
$3 = how many pings the router should send
And returns how many replies it received.
I didn't tried yet to store the ping count in a global variable, as I was convinced that was some kind of permission issue.
And about your third question: there's no error on any side. Just it receives 0 (zero) packets in return.
EDIT: I tried using just "/ping" instead of "/tool ping" and, yet, no packets.