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.

2
  • 1
    check this answer: stackoverflow.com/a/16665146/7302869 Commented Apr 7, 2017 at 18:16
  • You only have to store the command in a variable before exec Commented Apr 7, 2017 at 18:19

2 Answers 2

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;
Sign up to request clarification or add additional context in comments.

Comments

2

try using -v with rm this should throw verbose

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.