网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

linux系统shell脚本显示找不到文件怎么解决-创新互联

linux系统shell脚本显示找不到文件怎么解决?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

我们提供的服务有:网站制作、网站设计、微信公众号开发、网站优化、网站认证、东宁ssl等。为超过千家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的东宁网站制作公司

linux source shell脚本显示找不到文件

例子:

[root@localhost osc]# sh a.sh 
a.sh: line 4: source: 1.sh: file not found
[root@localhost osc]# cat a.sh 
#!/bin/bash
cd /data/osc/bin/
if [ -f 1.sh ];then
source 1.sh
fi

刚开始,还以为权限问题,然后给权限,但结果还是一样

man source ,找到原因了。source时找filename的问题。

source 命令找filename是在当前的shell环境下找的,如果没有反斜线,就在path中找,如果没有就没有。

source filename [arguments]
              Read  and  execute commands from filename in the current shell environment and return the exit status of the last command exe-
              cuted from filename.  If filename does not contain a slash, file names in PATH are used to find the directory containing file-
              name.   The  file  searched  for  in  PATH  need  not be executable.  When bash is not in posix mode, the current directory is
              searched if no file is found in PATH.  If the sourcepath option to the shopt builtin command is turned off, the  PATH  is  not
              searched.   If  any  arguments  are  supplied, they become the positional parameters when filename is executed.  Otherwise the
              positional parameters are unchanged.  The return status is the status of the last command exited within the script  (0  if  no
              commands are executed), and false if filename is not found or cannot be read.

如下方式都可以:

1、将脚本所在的目录加到PATH中

2、加上相对路径或绝对路径

3、就算是当前目录也得加./

看完上述内容,你们掌握linux系统shell脚本显示找不到文件的解决方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注创新互联成都网站设计公司行业资讯频道,感谢各位的阅读!

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


当前文章:linux系统shell脚本显示找不到文件怎么解决-创新互联
文章分享:http://bjjierui.cn/article/dissci.html

其他资讯