Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSTYPE not available in shell script

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.

like image 637
keiki Avatar asked May 02 '14 09:05

keiki


People also ask

What is Linux Ostype?

The ostype (sometimes called LUN multiprotocol type) specifies the OS of the host accessing the LUN. It also determines the layout of data on the LUN, the geometry used to access that data, and the minimum and maximum size of the LUN.

What is $() in shell script?

$() – the command substitution. ${} – the parameter substitution/variable expansion.


1 Answers

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.

like image 133
rojomoke Avatar answered Oct 03 '22 10:10

rojomoke