【问题标题】:bash command not found, or other workaround?找不到 bash 命令或其他解决方法?
【发布时间】:2011-05-31 12:20:15
【问题描述】:

我正在使用 Yii 的敏捷 Web 开发一书。在第 8 章中,它创建了一个 php 脚本来设置 RBAC(基于角色的访问控制),以便当我们访问 shell 时

/framework/yiic shell

它应该允许我们输入命令

rbac

根据我们创建的 PHP 脚本,该命令创建了三个角色,拥有不同权限的所有者、成员和读者。

我的问题是,当我使用 MAMP 执行命令时

yiic shell

它说

-bash: yiic: command not found

因此,我无法创建这些角色,然后我无法继续阅读本书,因为我不知道任何解决方法

有人可以帮忙吗?

更新 根据以下答案之一,我做了chmod +x yiic

现在,当我运行 /framework/yiic shell 时,它似乎进入了 shell,但与我的书中描述的不同

这本书告诉我我应该得到这个

    % YiiRoot/framework/yiic shell Yii Interactive Tool v1.1 (based on Yii v1.1.2) Please type 'help' for help. Type 'exit' to quit. >>
    Now type help to see a list of available commands:
 >> help
    At the prompt, you may enter a PHP statement or one of the following commands:
    - controller
 - crud 
- form
 - help

    - model
 - module 
- rbac
    Type 'help <command-name>' for details about a command.

但是,我得到了

USAGE
  yiic shell [entry-script | config-file]

DESCRIPTION
  This command allows you to interact with a Web application
  on the command line. It also provides tools to automatically
  generate new controllers, views and data models.

  It is recommended that you execute this command under
  the directory that contains the entry script file of
  the Web application.

PARAMETERS
 * entry-script | config-file: optional, the path to
   the entry script file or the configuration file for
   the Web application. If not given, it is assumed to be
   the 'index.php' file under the current directory.

【问题讨论】:

  • 我不太了解这类事情,但您可能需要将 yii 目录添加到 bash 配置文件中的 $PATH 中。
  • @sehe ,我输入了配置文件,它说“找不到命令”你知道我应该如何指定这些参数吗?

标签: php bash terminal yii


【解决方案1】:

尝试完整路径:

/framework/yiic shell

如果您想在不提供完整路径的情况下使用 yiic,则必须将 /framework/ 添加到您的 $PATH-环境变量中。

【讨论】:

  • 我在框架目录和 htdocs(包含框架)中都试过了,我得到“没有这样的文件或目录”
  • 您是否与ls /framework/ 核对文​​件是否在文件夹中以及是否可执行? chmod +x /framework/yiic
  • @cularis,我按照你的建议做了,它打开了一个 shell,但与书中描述的不一样。即它没有为我提供我正在寻找的命令。如果您能提供更多帮助,请查看我在 OP 中的更新。
  • @Michael 您必须将入口脚本或配置文件添加为参数,或者在入口脚本或配置文件所在的目录中启动 shell。
  • 您为本教程创建了一个 PHP 文件?在yiic shell 之后指定其路径。例如yiic shell /home/user/mywebapp.php
【解决方案2】:

您可能需要指定路径:

/framework/yiic 

或将目录包含在您的 PATH 中

PATH="$PATH:/framework"
export PATH

【讨论】:

  • 我会把它放在你需要的地方。仅有的。此外,在 bash 中,您可以一次性 export PATH="$PATH:/framework"
  • 在更改 yiic shell 的权限以使其可执行后,我现在可以访问 ./yiic shell 但是它不会打开我书中描述的相同 shell。即它没有给我我需要的命令,比如 crud 和 rbac。如果您能提供更多帮助,请参阅我的 OP 中的更新
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-06-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-02
  • 1970-01-01
相关资源
最近更新 更多