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去執(zhí)行。雖然dash和bash都是shell,在執(zhí)行時還是有差別的。
解決方法: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去執(zhí)行。雖然dash和bash都是shell,在執(zhí)行時還是有差別的。
(1)執(zhí)行時由sh build.sh變成bash build.sh可以解決此問題。
(2)ln -s /bin/bash /bin/sh -f
(3)sudo dpkg-reconfigure dash 進行配置,道理同(2)
歸結(jié)來說,為兩種方式。以上兩種方法都可以實現(xiàn)。
感謝http://blog.sina.com.cn/s/blog_7cb1c50e0100rapz.html博主。
|----------------------------------------------------------------------------------------|
版權聲明 版權所有 @zhyiwww
引用請注明來源 http://www.aygfsteel.com/zhyiwww
|----------------------------------------------------------------------------------------|