Php exec() error

execphp

I'm having a little problem with the following:

When I execute this line:

echo exec(createDir($somevariable));

I get this error:

Warning: exec() [function.exec]: Cannot execute a blank command in /home/mydir/myfile.inc.php on line 32

Any ideas.

Thanks.

Best Solution

exec() expects a string argument, which it would pass on to your operating system to be executed. In other words, this is a portal to the server's command line.

I'm not sure what function createDir() is, but unless it's returning a valid command line string, it's probably failing because of that.

In Linux, you might want to do something like

exec('/usr/bin/mkdir '.$path);

...on the other hand, you should abstain from using exec() at all costs. What you can do here, instead, is take a look at mkdir()