3

I am trying to set a view using -exec command because the script exits after setting the view using normal

cleartool setview <view name>

When I used the below command script doesn't exits but gives an error like -w invalid option

cleartool setview -exec -view <view name>
bash: -w: invalid option
Vinay Shukla
  • 1,818
  • 13
  • 41

1 Answers1

0

Simply don't use cleartool setview.
As I describe in "How to exit from clearcase view and not from script?":

any commands that appear after the execution of cleartool setview XYZ are not processed because a shell is spawned with exec(), which replaces the current program with a new program.

See more at "Python and ClearCase setview".


Instead, use the full path of the view /view/<view name>/vobs/yourVob, in order to launch your script.
(But first, make sure you start the dynamic view: cleartool startview <view name>)


If you still want to use setview, try at least:

cleartool setview -exec "yourScript" -view <view name>

Otherwise, -view would be interpreted as an option to -exec command, which makes no sense.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Cannot use use the full path of the view /view//vobs/yourVob as the names are different for different stgloc's. I am already running a script and inside this script when I try to set the view using `cleartool setview ` then the view gets set but the script exits automatically after setting the view. your explanation for -exec was really nice. – Vinay Shukla Nov 21 '13 at 06:46
  • @yanivx: yes, I would really avoid the `setview` complication all together. Using the direct path doesn't involve any sub-shell. – VonC Nov 21 '13 at 06:48
  • If possible suggest me how can I set a view and do not exit from the script as simple as that. – Vinay Shukla Nov 21 '13 at 06:53
  • @yanivx As I explain in the answer, you start a view, and then access its content through its path (`/view//vobs/yourVob`): your script can use that path directly: it won't exit because of that path. And starting a view won't cause your script to exit either. – VonC Nov 21 '13 at 07:07
  • To access its content I should be able to set the view right ??? No sooner I set the view I exit from the script. May be I am not getting you. check this link http://www-01.ibm.com/support/docview.wss?uid=swg21119859 and it suggests some alternatives none of them seem to work – Vinay Shukla Nov 21 '13 at 07:15
  • @yanivx No! No need to "set" a view. Do *not* use `cleartool setview aView` . Just do not use it. At all. Ever. Forget it. Use `cleartool startview aView` (that doesn't exit anything) and then access it through its full path `/view//vobs/yourVob`. – VonC Nov 21 '13 at 07:21
  • My script uses that view to deliver an activity associated with it so I need to set the view. I tried using `cleartool startview aView` after doing so I executed `cleartool pwv` and it shows NONE like this `Working directory view: ** NONE ** Set view: ** NONE **` Your solution would have worked if i had to just access the contents – Vinay Shukla Nov 21 '13 at 07:34
  • @yanivx yes, this is expected. You need a `cd` after your `startview`: `cleartool startview aView`, and `cd /view//vobs/yourVob`: *then* your `cleartool pwv` will work. Believe me. It works. And it doesn't exit of any script. – VonC Nov 21 '13 at 07:36
  • `cleartool startview ${views[$(($choice7 - 1))]} cd /vob/siren` is the code I am using in my script. I am trying hard to believe you but the results dont let me believe you. Using your solution I am not able to see the files too `{vinays@~}$ ct startview vinays_HPI_view {vinays@~}$ ct pwv Working directory view: ** NONE ** Set view: ** NONE ** {vinays@~}$ ct startview vinays_HPI_view ;cd /vob /siren/scm {vinays@/vob}$ ct pwv Working directory view: ** NONE ** Set view: ** NONE ** {vinays@/vob}$ ` – Vinay Shukla Nov 21 '13 at 07:50
  • 1
    @yanivx forget '`/vob`': that path only exist when you use `setview`. Again, use the **FULL PATH OF THE VIEW**: `/view/siren/vobs/YourVob`. I promise. It works. – VonC Nov 21 '13 at 07:53
  • @yanivx see more about that dynamic view full path at https://pic.dhe.ibm.com/infocenter/cchelp/v7r1m0/index.jsp?topic=/com.ibm.rational.clearcase.cc_ref.doc/topics/pathnames_ccase.htm – VonC Nov 21 '13 at 07:55
  • Your solution works to access the file and other commands like rebase status and complete are working fine but there is another issue I save the o/p of a `cleartool rebase -status >temp1.txt` and do a read line to check if any rebase is in progress but now It is not allowing me to create this temp1.txt file as I am inside the vob location `-bash: temp1.txt: Permission denied` i tried at other locations too still not success. The same script works fine when I set the view and then run the script – Vinay Shukla Nov 21 '13 at 08:40
  • 1
    @yanivx it depends on your current path (`pwd`) when you execute the `cleartool rebase`. `/views`, `/views/aView`, and `/views/aView/vobs` are not authorized for writing. But anything below that should be ok. So again, what is your *exact* path when doing the `>temp1.txt` redirection? What `pwd` returns just before that command? – VonC Nov 21 '13 at 08:42
  • Thanks :) working now sorry for my comment that I tried at a location inside i.e /vob/dir1 but when I tried /vob/dir1/dir2 it worked like a charm :) – Vinay Shukla Nov 21 '13 at 08:47
  • @yanivx Reminder: `/vob/xxx` is only valid when using `cleartool setview`. And I told you to *not* use `cleartool setview`, but to use full path for the view like `/views/aView/vobs/aVob/...`. So why are you mentionning `/vob`? – VonC Nov 21 '13 at 08:49
  • sorry for not writing the complete path what i meant was it failed for `/view/view-name/vob/dir1` but the same worked fine for `/view/view-name/vob/dir1/dir2 ` – Vinay Shukla Nov 21 '13 at 10:29
  • @yanivx ok, but is not `/view/view-name/vobs/xxx` instead of `/view/view-name/vob`? With an '`s`' to `vobs`, `/view/view-name/vobs/dir1` should be writable. – VonC Nov 21 '13 at 10:31
  • In my case no the name is `vob` and in dir1 is not writable – Vinay Shukla Nov 21 '13 at 10:41
  • @yanivx could you check if `/view/view-name/vobs/dir1` exists? `cd /view/view-name/vobs/dir1`. And see if you can write in it. – VonC Nov 21 '13 at 10:43