문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top