如何一次运行多个 Unix 命令 [英] How to run multiple Unix commands in one shot

查看:25
本文介绍了如何一次运行多个 Unix 命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图一次执行多个命令,但令我惊讶的是,只有第一个命令被执行,其余的被跳过.而命令是

cleartool setview view1234 ;cleartool setactivity activity456 ;cd/vobs/app/src/epw/WEB-INF/scripts ;密码

而上述命令的输出是

您现在可以运行clearquest"来启动 Rational ClearQuest.

但相反,我希望看到以下 3 行输出:

您现在可以运行clearquest"来启动 Rational ClearQuest.在视图view1234"中设置活动activity456"./vobs/app/src/epw/WEB-INF/scripts

通过将分号 (;) 替换为与号 (&) 或竖线 (|),我的搜索工作为同一命令产生了更多变化,但似乎没有任何效果.

有关如何运行上述多个命令的任何建议/想法?

解决方案

不要使用 cleartool setview:它在子shell中分叉当前shell,这就是为什么在一行中执行时会跳过其余部分.
这就是为什么它在一个一个执行时有效(最后两个在子shell中执行)

始终使用动态视图的完整路径:/view/aview/vobs/avob/...,而不是 setview(您不需要).

如果您必须使用 cleartool setview,然后将其与 -exec<一起使用/code> 选项(在这个答案中):

cleartool setview -login -exec "command 1;命令 2;命令 3"视图标签

就你而言:

cleartool setview -exec 'cleartool setactivity activity456 ;cd/vobs/app/src/epw/WEB-INF/scripts ;pwd' view1234


没有 setview:

OP 询问:

<块引用>

假设我名为 humanbeing 的视图位于 universe/planet/earth/humanbeing.vws

我如何使用startview 命令?
是不是类似

cleartool startview 宇宙/行星/地球/人类

<块引用>

cleartool startview cd 宇宙/行星/地球/人类

<块引用>

在这两种情况下,它都说错误:无法设置视图标签 universe/planet/earth/humanbeing

当然,做一个 cleartool lsview -s |grep humanbeing:这会给你视图标签.

应该是:

cleartool startview 人类cd/view/humanbeing/vobs/

universe/planet/earth/humanbeing.vws 是视图存储,不是视图标签.

确保

  • 已挂载 (cleartool mount/vobs/avob)
  • myapp/WEB-INF/scripts 存在于 /view/humanbeing/vobs/

不要尝试在 /vobs 中做任何符号链接:/vobs 是一个特殊的 MVFS(多版本文件系统)安装点,而不是常规文件夹.
确保您的 Web 应用程序在 /vobs 之外的其他路径中搜索应用程序.

I am trying to execute multiple commands in one shot but to my surprise only the first command is getting executed and the rest are skipped. And the command is

cleartool setview view1234 ; cleartool setactivity activity456 ; cd /vobs/app/src/epw/WEB-INF/scripts ; pwd

And the output of the above command is

You can now run 'clearquest' to start Rational ClearQuest.

But instead I'm expecting to see the following 3 lines of output:

You can now run 'clearquest' to start Rational ClearQuest.
Set activity "activity456" in view "view1234".
/vobs/app/src/epw/WEB-INF/scripts

My search efforts yielded few more variations for the same command by replacing semicolon(;) with ampersand (&) or pipe (|) but nothing seems to be working.

Any suggestions/ideas on how to run multiple commands like above?

解决方案

Don't use cleartool setview: it forks the current shell in a subshell, which is why the rest is skipped when executed in a single line.
And which is why it works when executed one by one (the last two are executed in the subshell)

Always work with the full path of the dynamic view: /view/aview/vobs/avob/..., instead of setview (which you don't need).

If you must use cleartool setview, then use it with the -exec option (as in this answer):

cleartool setview -login -exec "command 1; command 2; command 3" view_tag

In your case:

cleartool setview -exec 'cleartool setactivity activity456 ; cd /vobs/app/src/epw/WEB-INF/scripts ; pwd' view1234 


Without setview:

The OP asks:

Say my view named humanbeing is in universe/planet/earth/humanbeing.vws

How do I use the startview command?
Is it something like

cleartool startview universe/planet/earth/humanbeing

or

cleartool startview cd universe/planet/earth/humanbeing

In both the cases it says the Error: Couldn't set view tag universe/planet/earth/humanbeing

To be sure, do a cleartool lsview -s | grep humanbeing: that will give you the view tag.

That should be:

cleartool startview humanbeing
cd /view/humanbeing/vobs/<avob>

universe/planet/earth/humanbeing.vws is the view storage, not a view tag.

Make sure that

  • is mounted (cleartool mount /vobs/avob)
  • myapp/WEB-INF/scripts is present in /view/humanbeing/vobs/<avob>

Don't try to do any symlink in /vobs: /vobs is a special MVFS (Multi-Version FileSystem) mounting point, not a regular folder.
Make sure your webapp search for apps in another path than /vobs.

这篇关于如何一次运行多个 Unix 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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