简体   繁体   English

如何在我的 bash 脚本中打印 TCL 环境变量

[英]How do I print TCL environment variable in my bash script

TCL script TCL 脚本

set ::env(foo) "bar"

bash script bash 脚本

echo ${env(foo)}
echo $foo

I am able to print the environment variable in the TCL script but for some reason I can't print the environment variable in my bash script.我可以在 TCL 脚本中打印环境变量,但由于某种原因,我无法在我的 bash 脚本中打印环境变量。 What am I doing wrong?我究竟做错了什么?

If your bash script contains something like this (let's call it showenv )如果您的 bash 脚本包含类似这样的内容(我们称之为showenv

#! /bin/bash

echo $foo

and your tcl和你的 tcl

#! /usr/bin/tclsh

set ::env(foo) bar

exec ./showenv >>& /dev/tty

then, showenv will show然后, showenv将显示

bar

that is, the tcl script sets the environment for its children processes.也就是说,tcl 脚本为其子进程设置环境。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在将由 Bash 运行的脚本的 shebang (#!) 中设置环境变量? - How do I set an environment variable in the shebang (#!) of a script that will be run by Bash? 如何在 sh bash 脚本块中打印 Jenkins 环境变量 - How to print a Jenkins environment variable inside a sh bash script block 如何在 bash 脚本中将 TCL 变量设置为变量 - How to set a TCL variable as a varible in a bash script 在 Bash 脚本中,如何以使用逗号分隔格式化变量的方式打印包含字符和数字变量的字符串? - In Bash script, how do I print a string with characters and a number variable in a way that the variable is formatted with comma separation? 如何在bash脚本中执行我的环境变量中的程序 - how to execute program which is in my environment variable in a bash script 从 Bash 脚本,如何调用命令字符串中包含的 Linux 环境变量? - From Bash script, how do I call a Linux environment variable contained in a command string? 如何将 shell 中的所有环境变量传递给它调用的 bash 脚本? - How do I pass all the environment variables from my shell to the bash script it calls? 如何在BASH脚本发送的电子邮件中正确打印多行变量? - How do I properly print a multi-line variable in an e-mail sent from a BASH script? 如何从脚本中设置bash环境变量? - How do I set bash environment variables from a script? 如何在bash的别名中包含环境变量? - How do I include an environment variable inside an alias for bash?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM