站长论坛

标题: 让脚本程序设置为可执行 [打印本页]

作者: superadmin    时间: 2008-6-19 09:41
标题: 让脚本程序设置为可执行
执行脚本程序的方式:
l1、将程序文件作为shell的参数:
   /bin/sh first.sh   以默认shell来运行first.sh
   /bin/bash first.sh 指定bash shell来运行first.sh
l2、通过chmod将脚本程序修改为可执行:
   chmod +x first.sh
   这时在命令行输入first.sh时,通常会报错:
   -bash: first.sh: command not found
  
解决方法:
   1、使用./方法:./first.sh (这种方法是把文件相对路径通知给shell)    /*推荐使用*/
   2、将脚本程序文件拷贝到PATH变量所指定的目录中。
   3、将当前目录临时添加到PATH变量中:“PATH=$PATH:.”     /*建议不要使用*/




欢迎光临 站长论坛 (http://tzlink.com/bbs/) Powered by Discuz! X3.2