开发者

How to change shell in script temporary in sunOS?

The machine has default shell "sh" and running SunOS. I try to run the script like:

#!/bin/bash
export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P9
echo $NLS_LANG

I get the output:

NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P9^M: is not an identifier

I think th开发者_开发知识库e script cannot execute this command but do not understand why. Maybe It is because the default shell is not bash shell.

Could you help me to convert sh shell into bash shell inside of the script.

P.S: I have also tried with #!/bin/sh but result is the same


Your script is using the wrong line endings. Run it through dos2unix.


Are you sure that Bash is where you say it is? Consider using the following shebang:

bash-3.2$ cat ./test.sh
#!/usr/bin/env bash
export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P9
echo $NLS_LANG

Ensure your shell script is executable:

bash-3.2$ chmod +x ./test.sh
bash-3.2$ ls -l ./test.sh
-rwxr-xr-x  1 paj  staff  81 26 Apr 11:52 ./test.sh

And run...

bash-3.2$ ./test.sh
AMERICAN_AMERICA.WE8ISO8859P9
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜