免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1398 | 回复: 4
打印 上一主题 下一主题

执行shell脚本的时候为什么有的时候不加"./"就不能执行呢? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-03-20 14:02 |只看该作者 |倒序浏览
这样执行就会报错
$ exec_t.sh
sh: exec_t.sh:  not found.
而这样才能执行
$ ./exec_t.sh

本来以为在自己的$HOME目录下不用加"./" 但是还是不行呀

请大侠们帮忙解释一下,谢谢了

论坛徽章:
8
摩羯座
日期:2014-11-26 18:59:452015亚冠之浦和红钻
日期:2015-06-23 19:10:532015亚冠之西悉尼流浪者
日期:2015-08-21 08:40:5815-16赛季CBA联赛之山东
日期:2016-01-31 18:25:0515-16赛季CBA联赛之四川
日期:2016-02-16 16:08:30程序设计版块每日发帖之星
日期:2016-06-29 06:20:002017金鸡报晓
日期:2017-01-10 15:19:5615-16赛季CBA联赛之佛山
日期:2017-02-27 20:41:19
2 [报告]
发表于 2006-03-20 14:12 |只看该作者
man bash:


  1. After a command has been split into words, if it results in a simple command and an optional list of arguments, the following actions are taken.

  2. If the command name contains no slashes, the shell attempts to locate it. If there exists a shell function by that name, that function is invoked as described above in FUNCTIONS. If the name does not match a function, the shell searches for it in the list of shell builtins. If a match is found, that builtin is invoked.

  3. If the name is neither a shell function nor a builtin, and contains no slashes, bash searches each element of the PATH for a directory containing an executable file by that name........

复制代码

论坛徽章:
0
3 [报告]
发表于 2006-03-20 17:37 |只看该作者
原帖由 fox_fox 于 2006-3-20 14:02 发表
本来以为在自己的$HOME目录下不用加"./" 但是还是不行呀

provided $HOME is in $PATH ,
try this
export PATH=$PATHHOME

论坛徽章:
0
4 [报告]
发表于 2006-03-20 19:53 |只看该作者
好用了,谢谢各位老大

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
5 [报告]
发表于 2006-03-20 20:48 |只看该作者
一般勢將 $HOME/bin 加入 PATH.
然後將 program 放進去.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP