使用 sudo 运行 PHPdoc 的 SH 脚本
如何在 PHPdoc 生成文档时运行以下脚本?
#1 sudo -code
sudo source makedoc.sh
我
no command source
在没有 sudo 的情况下得到 #2
问题是 sudo
没有命令 来源
。 我试图通过将 ~/phpdoc/phpdoc 的权限更改为 777 来解决问题,但没有成功,然后运行
source makedoc.sh
我得到
makedoc.sh:90: permission denied: /home/masi/phpdoc/phpdoc
#3 没有 sudo
我运行
phpdoc -c makedoc.sh
我得到
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
文件 makedoc.sh 是否有一个 shebang 行(例如!#/usr/bin/bash)以便可以将其设为可执行文件?
然后
sudo ./makedoc.sh
看看会发生什么。
./ 表示在当前目录中运行 makedoc.sh (它应该修复找不到文件的错误)
授予 777 权限允许任何人读取、写入或执行文件。这就是迈克·阿瑟提到的安全风险。这可能更具潜在风险,但让其他人轻松修改、删除或执行您的文件绝不是好习惯。
Does the file makedoc.sh have a shebang line (eg !#/usr/bin/bash) so it can be made executable?
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.
sudo source 没有什么意义,您正在以 root 用户身份创建一个新 shell,然后尝试更改环境,然后该环境将被 root shell 破坏。
另外,仅当您想在当前 shell 中更改环境时才使用源代码,我很确定您不想使用名为“makedoc.sh”的东西来执行此操作。
您可能只想运行:
另外,永远不要将设置设置为 777,这永远不是问题的解决方案,而且存在安全风险。
sudo source makes very little sense, you are making a new shell as the root user and then trying to change the environment which will then be destroyed with the root shell.
Also, source is only used if you want to be getting changing your environment in the current shell which I'm pretty sure you wouldn't want to be doing with something called "makedoc.sh".
You probably just want to run:
Also, never set things to 777, it's never the solution to the problem and it's a security risk.
makedocs.sh 存在的一个原因是当您总是想重用相同的运行时设置时,它是一个方便的 shell 脚本,供您使用。。这不是一般情况下运行 phpDocumentor 的方式。
如果您尝试简单地针对您自己的代码运行 phpDocumentor 以便为其创建文档,那么您需要编辑 makedocs.sh 以将所有运行时参数设置为您想要的值。特别是, -t 参数指定应写入文档的目标位置。
实际上,不需要使用 sudo 来执行 phpdoc,除非您尝试将生成的文档直接写入系统范围的 PEAR 安装的“doc_dir”位置。在这种情况下,由于 root 拥有 PEAR,因此需要 sudo。也许您的需求不要求将您的文档写入该位置?
The one reason for makedocs.sh's existence is to be a convenient shell script for you to use when you always want to reuse the same runtime settings. It is not the way to run phpDocumentor in general.
If you are trying to simply run phpDocumentor against your own code in order to create docs for it, then you need to edit makedocs.sh to set all the runtime arguments to exactly what you want them to be. In particular, the -t argument to specify the target location where the docs should be written.
Really, there should be no need to use sudo to execute phpdoc, unless you are attempting to have the generated documentation written directly into your system-wide PEAR installation's "doc_dir" location. In this case, since root owns PEAR, sudo would be necessary. Maybe your needs do not require your docs to be written to that location?