从 bash 运行 csh 脚本,通过命令临时更改 shell

发布于 2024-10-01 16:18:53 字数 220 浏览 0 评论 0原文

我需要从 bash shell 运行 csh 脚本,因此通过命令临时更改为 tcsh。它在交互模式下工作得很好,但我无法用一行命令弄清楚。 因此,在交互模式下,我在 bash shell 中执行以下操作:

tcsh

source my.tcshr

useMyTcshCmd

等。

我如何在 1 个命令中完成所有这些操作? 抱歉新手问题...

I need to run csh scripts from a bash shell and therefore temporary change to tcsh via a command. It works perfect in interactive mode but i cant figure out in a one line command.
So in interactive mode i do in the bash shell:

tcsh

source my.tcshr

useMyTcshCmd

etc.

How can i do all of this in 1 command?
Sorry for the newbie question...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

往日情怀 2024-10-08 16:18:53
tcsh -c "echo foo; echo bar"

结果:

foo
bar

所以这应该有效:

tcsh -c "source my.tcshr; useMyTcshCmd"
tcsh -c "echo foo; echo bar"

Result:

foo
bar

So this should work:

tcsh -c "source my.tcshr; useMyTcshCmd"
多情出卖 2024-10-08 16:18:53

您应该直接在脚本中指定解释器:

#!/usr/bin/tcsh
echo "doing stuff"

然后只需运行脚本:

./script

You should specify the interpreter directly in the script:

#!/usr/bin/tcsh
echo "doing stuff"

And then simply run the script:

./script
伪装你 2024-10-08 16:18:53
tcsh -c useMyTcshCmd
tcsh -c useMyTcshCmd
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文