0

I am debugging a script that is supposed to delete a file and would love to know if there is a way to echo back the command I am running along with the results:

echo exec("rm ./" . strtolower(end(split('\/',$originalName))));

This will return the result, but with the incoming data (which should be something like:/plugins/Dropzone/files/xcqzr.png) it would be great to know what exactly is getting passed into it. I know I could do it in a separate process, but wondering if there was a built in way.

Alan
  • 2,046
  • 2
  • 20
  • 43

2 Answers2

3

You compose the command string beforehand and then pass it to exec().

$command = "rm ./" . strtolower(end(split('\/',$originalName)));
echo 'Command: '.$command.PHP_EOL;
$result = exec($command);
echo 'Result: '.$result.PHP_EOL;
pilsetnieks
  • 10,330
  • 12
  • 48
  • 60
2

try using -v with rm this should throw verbose

echo exec("rm -v ./" . strtolower(end(split('/',$originalName))));

Deepak Kedia
  • 174
  • 9