OSTYPE not available in shell script

六眼飞鱼酱① 提交于 2019-12-23 07:56:25

问题


Currently I'm setting up a new system using the new Xubuntu trusty tahr. I'm not very familiar with shell scripting, but I have one which needs the OSTYPE environment variable to determine what to do.

If I call echo $OSTYPE in the xfce-terminal I get succesfully linux-gnu.

If I call following script I only get an empty line.

#!/bin/sh
echo $OSTYPE

Am I missing something or is it maybe a problem of the new ubuntu?

On another machine of mine it works with that script. But I don't know if something was changed for that, because the system was originally not mine.


回答1:


The OSTYPE environment variable is not recognized by the original Bourne shell, which is what is being invoked by the first line of your script.

Replace it with:

#!/bin/bash

or

#!/bin/ksh

as appropriate to your setup.



来源:https://stackoverflow.com/questions/23424783/ostype-not-available-in-shell-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!