Shell脚本执行时出现declare: not found的解决方法
来源:互联网 发布:excel下拉菜单选择数据 编辑:程序博客网 时间:2024/05/18 02:49
错误现象:
(1)执行时由sh build.sh变成bash build.sh可以解决此问题。
(2)ln -s /bin/bash /bin/sh -f
(3)sudo dpkg-reconfigure dash 进行配置,道理同(2)
归结来说,为两种方式。以上两种方法都可以实现。
感谢http://blog.sina.com.cn/s/blog_7cb1c50e0100rapz.html博主。
deployer@andy-VirtualBox:~/pds/EB$ sh build.sh
build.sh: 18: build.sh: declare: not found
build.sh: 25: build.sh: declare: not found
build.sh: 32: build.sh: declare: not found
原因分析:
所以,问题出在,我们的脚本是bash的脚本。而用dash去执行。虽然dash和bash都是shell,在执行时还是有差别的。
解决方法:build.sh: 18: build.sh: declare: not found
build.sh: 25: build.sh: declare: not found
build.sh: 32: build.sh: declare: not found
原因分析:
root@andy-VirtualBox:/home/deployer/pds/EB# file /bin/sh
/bin/sh: symbolic link to `dash'
root@andy-VirtualBox:/home/deployer/pds/EB# file /bin/dash
/bin/dash: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x5d23ca7cbab4993f295d1089b4860eb32d406fab, stripped
root@andy-VirtualBox:/home/deployer/pds/EB# file /bin/bash
/bin/bash: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xf199a4a89ac968c2e0e99f2410600b9d7e995187, stripped
root@andy-VirtualBox:/home/deployer/pds/EB# ln -s /bin/bash /bin/sh
ln: failed to create symbolic link `/bin/sh': File exists
root@andy-VirtualBox:/home/deployer/pds/EB# ln -s /bin/bash /bin/sh -f
root@andy-VirtualBox:/home/deployer/pds/EB# file /bin/sh
/bin/sh: symbolic link to `/bin/bash'
重点看红色字体部分,可以看到,初始是/bin/sh是到/bin/dash的链接。修改后为到/bih/bash的链接。/bin/sh: symbolic link to `dash'
root@andy-VirtualBox:/home/deployer/pds/EB# file /bin/dash
/bin/dash: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x5d23ca7cbab4993f295d1089b4860eb32d406fab, stripped
root@andy-VirtualBox:/home/deployer/pds/EB# file /bin/bash
/bin/bash: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xf199a4a89ac968c2e0e99f2410600b9d7e995187, stripped
root@andy-VirtualBox:/home/deployer/pds/EB# ln -s /bin/bash /bin/sh
ln: failed to create symbolic link `/bin/sh': File exists
root@andy-VirtualBox:/home/deployer/pds/EB# ln -s /bin/bash /bin/sh -f
root@andy-VirtualBox:/home/deployer/pds/EB# file /bin/sh
/bin/sh: symbolic link to `/bin/bash'
所以,问题出在,我们的脚本是bash的脚本。而用dash去执行。虽然dash和bash都是shell,在执行时还是有差别的。
(1)执行时由sh build.sh变成bash build.sh可以解决此问题。
(2)ln -s /bin/bash /bin/sh -f
(3)sudo dpkg-reconfigure dash 进行配置,道理同(2)
归结来说,为两种方式。以上两种方法都可以实现。
感谢http://blog.sina.com.cn/s/blog_7cb1c50e0100rapz.html博主。
0 0
- Shell脚本执行时出现declare: not found的解决方法
- 嵌入式 Shell脚本执行时出现declare: not found的解决方法
- 执行shell脚本中declare: not found
- 执行shell脚本中declare: not found
- Ubuntu 下运行 Shell 脚本时显示 "declare not found" 的问题
- Ubuntu 下运行 Shell 脚本时显示 "declare not found" 的问题
- Ubuntu下运行Shell脚本时显示“declare not found”的问题
- ubuntu 下运行shell时的declare not found
- bash脚本中出现[[:not found错误的解决方法
- 在ubuntu下出现declare:not found的问题
- 在ubuntu下出现declare:not found的问题
- 文章标题Ubuntu下运行shell程序出现 declare:not found 错误
- 在执行shell脚本时,出现“syntax error : unexpected end of file"错误的解决方法
- Linux shell脚本执行提示错误[[: not found
- shell脚本执行错误 $'\r':command not found
- Mac执行shell脚本提示command not found的一种解决方案
- ubuntu 14.04环境下执行adb shell 时报错 error: device not found.的解决方法
- linux出现command not found的解决方法
- 学习笔记:window7环境下的nodejs与npm安装。
- JAVA并发API源码解析:原子类
- firefox 书签同步 xmark + 坚果云webDav
- iOS SDK详解之NSFileManager
- Windows Phone 学习 创建和使用数据库
- Shell脚本执行时出现declare: not found的解决方法
- OC的copy与mutableCopy剖析(copy篇)
- hdu 3335 Divisibility(Dancing Links 重复覆盖)
- 第三章第二十七题
- Iaas Paas Saas
- Eclipse 集成maven 提示错误
- X264 related resource
- 设计模式(4)——Factory method(工厂方法)
- Sum root to leaf number - LeetCode