Answer the question
In order to leave comments, you need to log in
How to execute shell using php?
Hello!
Here is a command that works fine with ssh:
curl https://sandbox.zamzar.com/v1/files/9364488/content \
-u f9b: \
-L \
-O \
-J
$output = shell_exec('curl https://sandbox.zamzar.com/v1/files/9364488/content \ -u f9bddee74f393cf0f8a316771b0041fad5ca0f6a: \ -L \ -O \ -J');
Answer the question
In order to leave comments, you need to log in
It's about backslashes. The backslash followed by a line break is ignored, so you can split the command over multiple lines. When you write the command on one line, the backslashes become independent arguments that curl doesn't know what to do with and throws an error. The error is thrown on stderr, which is ignored by shell_exec, so you don't see anything. That is, to execute a command, you need to either return line breaks or remove slashes.
Well, a legitimate question. Why do you need to pull curl through shell_exec if it can be pulled using PHP itself?
`curl https://sandbox.zamzar.com/v1/files/9364488/content ...`
curl is not a global command. this is an executable file that is somewhere, for example, in /usr/bin/curl. it is better to write the full path, because the PATH variable may be set in the shell, but in php it may not be
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question