[英]How can I make a hybrid bash/tcsh script on Linux?
I have one script which runs in Bash and and other which runs in tcsh. 我有一个在Bash中运行的脚本,另一个在tcsh中运行。
I need to run them both from the same script. 我需要从同一脚本运行它们。 How can I create a script that can run both bash and tcsh commands?
如何创建可以同时运行bash和tcsh命令的脚本?
Most shells have an argument which allow you to pass them a string to run as a command, for example, for bash you can run 大多数shell都有一个参数,允许您向其传递一个字符串以作为命令运行,例如,对于bash来说,您可以运行
bash -c "echo this is a bash script; echo lalalala"
to run that string as a script in bash, use this to run the needed shell embedded in the other. 要在bash中将该字符串作为脚本运行,请使用它运行嵌入到另一个脚本中的所需shell。 This will allow you to make a script in one shell which will invoke the other shell when the other program needs to be run.
这将允许您在一个shell中创建脚本,该脚本将在需要运行另一个程序时调用另一个shell。
If on the other hand they are both properly shebanged begin with #!tcsh
or #!bash
you can simply run both scripts from the same bash script using: 另一方面,如果它们都正确地以
#!tcsh
或#!bash
开头,则可以使用以下命令从同一bash脚本运行两个脚本:
/path/to/script1 &
/path/to/script2 &
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.