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

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

问题描述

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

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

上述命令的输出为

 现在,您可以运行'clearquest'启动Rational ClearQuest。 

但是我期望看到以下3行输出:

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

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



任何建议/

解决方案

不要使用 cleartool setview 它分叉了当前外壳程序放在子外壳程序中,这就是为什么在一行中执行其余操作时会跳过其余外壳程序的原因。
并且这也是为什么它在一个接一个地执行时起作用的原因(后两个在

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


如果必须使用 cleartool setview ,然后将其与 -exec 选项(如本答案所示):

  cleartool setview -login -exec"命令1;命令2;命令3; view_tag 

在您的情况下:

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




无setview:


OP询问:


说出我的名为 human 的视图在 universe /中planet / earth / humanbeing.vws


如何使用 startview 命令

是否类似于



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





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



在两种情况下均显示错误:无法设置视图标记 universe /地球/地球/人类


可以肯定的是,使用 cleartool lsview -s | grep humanbeing :将为您提供视图标签。


应为:

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

universe / planet / earth / humanbeing.vws 是视图存储,而不是视图标记。


请确保已安装



  • cleartool mount / vobs / avob

  • myapp / WEB-INF / scripts 出现在 / view / humanbeing / vobs /< avob>


/ vobs 中执行任何符号链接: / vobs 是特殊的MVFS(多版本文件系统)安装点,不是一个普通文件夹。

确保您的网络应用程序在 / 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天全站免登陆