Search code examples
phppermissionssudophpdoc

Running SH script with sudo for PHPdoc


How can you run the following script in generating docs by PHPdoc?

#1 sudo -code

sudo source makedoc.sh

I get

no command source

#2 without sudo

The problem is that sudo does not have the command source. I tried to fix the problem unsuccessfully by changing the persmissions of ~/phpdoc/phpdoc to 777 and then running

source makedoc.sh

I get

makedoc.sh:90: permission denied: /home/masi/phpdoc/phpdoc

#3 without sudo

I run

 phpdoc -c makedoc.sh

I get

codes master $ phpdoc -c makedoc.sh
PHP Version 5.2.6-3ubuntu4.2
phpDocumentor version 1.4.2

Parsing configuration file phpDocumentor.ini...
   (found in /usr/share/php/data/PhpDocumentor/)...

done
Maximum memory usage set at 256M after considering php.ini...
using tokenizer Parser
a target directory must be specified
 try phpdoc -h

Solution

  • Does the file makedoc.sh have a shebang line (eg !#/usr/bin/bash) so it can be made executable?

    chmod +x makedoc.sh
    

    Then

    sudo ./makedoc.sh

    and see what happens.

    The ./ means run makedoc.sh in the current directory (it should fix the file not found error)

    Giving permissions of 777 allows anyone to read, write or execute the files. This is the security risk Mike Arthur referred to. It may be more of a potential risk, but it's never good practice to make it easy for others to modify, delete or execute your files.