os.system()在哪个linux shell下执行命令? [英] os.system() execute command under which linux shell?

查看:281
本文介绍了os.system()在哪个linux shell下执行命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将/bin/tcsh用作默认外壳.

I am using /bin/tcsh as my default shell.

但是,tcsh样式命令os.system('setenv VAR val')对我不起作用.但是os.system('export VAR = val')有效.

However, the tcsh style command os.system('setenv VAR val') doesn't work for me. But os.system('export VAR=val') works.

所以我的问题是我如何知道os.system()在哪个shell下运行命令?

So my question is how can I know the os.system() run command under which shell?

推荐答案

os.system()仅调用system()系统调用("man 3 system").在大多数* nixes上,这意味着您会得到/bin/sh.

os.system() just calls the system() system call ("man 3 system"). On most *nixes this means you get /bin/sh.

请注意,export VAR=val在技术上不是标准语法(尽管bash可以理解,但我认为ksh也可以).它在/bin/sh实际上是Bourne shell的系统上不起作用.在这些系统上,您需要导出并设置为单独的命令. (这也适用于bash.)

Note that export VAR=val is technically not standard syntax (though bash understands it, and I think ksh does too). It will not work on systems where /bin/sh is actually the Bourne shell. On those systems you need to export and set as separate commands. (This will work with bash too.)

这篇关于os.system()在哪个linux shell下执行命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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