0

I have set up the CakePHP Console (CakePHP 2.5.3) and created the Shell UpdateShell.php:

<?php
class UpdateShell extends AppShell {

public function main() {

    exec('touch /test.tmp');

}

When I try to execute this Shell, it shows the error sh: /touch: not found

The same error occurs if I want to copy a file, then it says sh: /cp: not found

Im trying to execute it the following way:

  • log in with terminal: ssh root@myserver.com
  • go to app folder: cd /path_to_my_cakephp_folder/app/
  • execute cake shell: Console/cake update

I'm on Ubuntu 10.04.3 LTS.

Any ideas apprechiated, I've been trying for hours.

Stephan Wagner
  • 990
  • 1
  • 8
  • 17
  • PHP has a [`touch()`](http://php.net/touch) function... – Martin Tournoij Aug 25 '14 at 15:59
  • yea, but I need to copy files, I use `touch` for testing, it should be able to do that with the shell, I works when I type it in directly – Stephan Wagner Aug 25 '14 at 16:01
  • [`copy()`](http://php.net/copy), [Recursive Copy of Directory](http://stackoverflow.com/questions/5707806/recursive-copy-of-directory) ... I don't know anything about CakePHP, but you (almost) never need to execute shell commands in a highlevel language (like PHP). – Martin Tournoij Aug 25 '14 at 16:04
  • sure its possible, but i need it in shell! I want to copy thousands of files, multiple times, takes forever with php, takes less than a second with shell. As I said the above is just an example that needs to work, once I got this working I can build my shell script which uses many shell commands, including `touch` and `cp` – Stephan Wagner Aug 25 '14 at 16:08
  • If you have to execute shell commands, have you tried using the absolute path to the executable, e.g. `/usr/bin/touch`? – zerodiff Aug 25 '14 at 16:08
  • same error: `exec('/usr/bin/touch /test3333.tmp');` > `sh: /touch: not found` – Stephan Wagner Aug 25 '14 at 16:10
  • The fact that the `sh` output prepends all your commands with a leading slash worries me. What kind of setup are you on? It looks like some sort of chrooted environment? In that case you'll need to use full paths for binaries that you actually have access to. – Oldskool Aug 25 '14 at 19:52

0 Answers0