如何删除“未设置TERM环境变量" [英] how to remove "TERM environment variable not set"

查看:28
本文介绍了如何删除“未设置TERM环境变量"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本 runonce.sh,它通过 cron 调用另一个脚本 setup.sh.我们认为这种情况是未设置 TERM 环境变量"的理想情况.在 runonce.sh 脚本的输出中可以看到.

I am having a script runonce.sh who calls another script setup.sh through cron. We consider this case as ideal case where "TERM environment variable not set." is seen in output of runonce.sh script.

现在我面临一个问题,即调用 setup.sh 时另一个第三个简单的脚本 - upgradeAndTest.sh,当时也未设置 TERM 环境变量".在 upgradeAndTest.sh 脚本的输出中可以看到.为什么会这样..?

Now I am facing a problem that another third simple script - upgradeAndTest.sh when calls setup.sh, that time also "TERM environment variable not set." is seen in output of upgradeAndTest.sh script. Why is so..?

此外,如果我在调用脚本中将 setup.sh 的 stderr 重定向到 stdout,那么也会未设置 TERM 环境变量".显示在控制台上.

Also, if I redirect stderr of setup.sh to stdout in calling script then also "TERM environment variable not set." displays on console.

谁能帮我从调用脚本的标准输出中删除这一行..?

Can any one help me to remove this line from stdout of calling script..?

推荐答案

通过 cron 运行需要终端的程序会导致问题;当它由 cron 运行时,它不会有终端.

Running a program that demands a terminal via cron can lead to problems; it won't have a terminal when it is run by cron.

如果有疑问,请确保在脚本中设置了该变量,方法是添加一行:

In case of doubt, though, ensure that the variable is set in the script, by adding a line:

export TERM=${TERM:-dumb}

如果环境变量 TERM 已经设置,这是一个空操作.如果不是,它会将终端设置为具有最小功能的标准终端——这满足了抱怨 TERM 未设置的程序.

If the environment variable TERM is already set, this is a no-op. If it is not, it sets the terminal to a standard one with minimal capabilities — this satisfies the program that complains about TERM not being set.

这篇关于如何删除“未设置TERM环境变量"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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