OSTYPE在Shell脚本中不可用 [英] OSTYPE not available in shell script

查看:233
本文介绍了OSTYPE在Shell脚本中不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在使用新的Xubuntu可信赖的Tahr来建立新系统. 我对shell脚本不是很熟悉,但是我有一个需要OSTYPE环境变量来确定要执行的操作.

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.

如果在xfce终端中调用echo $OSTYPE,我将成功获得linux-gnu.

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

我是否缺少某些东西,或者可能是新的Ubuntu问题?

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.

推荐答案

原始的Bourne shell无法识别OSTYPE环境变量,这是脚本第一行所调用的.

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.

替换为:

#!/bin/bash

#!/bin/ksh

根据您的设置.

这篇关于OSTYPE在Shell脚本中不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆