Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
771 views
in Technique[技术] by (71.8m points)

ssh - How to run multiple Unix commands in one shot

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...