Re: exec returns no output?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, September 30, 2006 7:22 am, Nick Wilson wrote:
> i've searched and racked my brains, checked config files and all sorts
> but cannot work out why the following command would give me an empty
> array (and certainly not actually perform the requested command...)
>
> exec('scp -v -i /id_dsa file.txt user@xxxxxxxxxx:/target/dir/',
> $argh);
> print_r($argh);
>
> I can only surmise there is some setting todo with ssh/scp that im
> unaware of?

For starters, you should us a FULL PATH to /id_dsa because the shell
exec() uses is not a full-blown shell in your home directory.

Next, you have to realize that PHP does not run as "you" but as
"nobody" or "www" or some similarly less-enabled user, for security
reasons, on most setups.

Third, you should use the optional third argument to exec() so you can
get the OS error number of what went wrong.  For bonus points, you can
install my http://l-i-e.com/perror module to get the error number
converted to a nice string, or you can fire up an ssh shell and do:
perror ## where ## is what came back in this optional third argument.

Fourth, you really should use the full path to scp, as, again, the
shell exec() is using is not a full-blown shell like you get when you
login, and PHP is not running as "you" so may not even have permission
to run scp.

Did I mention that PHP doesn't run as you, so this all boils down to a
permissions problem? :-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux