本文介绍了问题执行的bash文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!

我同时学习.SH合并文件和PHP碰到一些问题。我已经创建一个文件test.sh,并在该文件中我称之为叫test.php的PHP文件。

I've run into some problem while learning to combine .sh files and PHP. I've create a file test.sh and in that file I call a PHP file called test.php.

如果我双击该.SH文件,然后运行完美,但是当我尝试从终端中运行它,我得到未找到命令。我在精确的文件夹我的sh文件,但它不会工作。这里是我的test.sh:

If I double click on the .sh file then it runs perfectly but when I try to run it from the terminal I get "command not found". I'm in the exact folder as my .sh file but it wont work. Here's my test.sh:

#!/bin/bash
LIB=${0/%cli/}
exec php -q ${LIB}test.php one two three
exit; 

当我双击在test.sh文件,则返回argv数组喜欢suppost来。但是,为什么我不能从终端中运行呢?

When I doubleclick on the test.sh file then it returns the argv array like it suppost to. But why can't I run it from terminal?

推荐答案

使用 ./ filename.sh

不管你是否在同一个文件夹或没有,没有给./系统搜索路径变量。 (/斌/是/ usr /仓等)

no matter if your are in the same folder or not, without giving ./ the system is searching the path variable. (/bin/, /usr/bin and so on)

这篇关于问题执行的bash文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 15:59