seeing if server allows use of ftp_exec for cli commands

90 views Asked by At

So I've been doing some conditional test, and yet I am getting errors. Basically what I am trying to do is see if using CLI with ftp_ functions will work on a server.

My test:

if(ftp_exec($connect,'ls -l'))
   $canuse = true;
else
   $canuse = false;

But this does not work on my server as it is blocked. Is there a test I can do without getting these errors and ruining my JSON (this trial returns a block of json)

1

There are 1 answers

0
Marc B On BEST ANSWER

You can either turn off all of the error_reporting/display_error options, so the warnings/errors are suppressed, or you could try the OB system to catch the junk:

... build some json
ob_start();
... do ftp tests
$junk = ob_end_clean();
... build more json

All of the ftp errors would get caught in the ob buffer, and then thrown away when you shut down the buffer at the conclusion of the ftp test.