Question

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.

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top