2

We use an rsh command to check files into ClearCase:

<cfexecute name="C:\cygwin64\bin\rsh.exe"
    arguments="-n -l #USERNAME# #SERVER# ""cleartool setview -exec '#KSH_FILE# -user #USERNAME# -dir #VOB_DIRECTORY#' #CLEARCASE_VIEW#"" "
    timeout="180"
    variable="CHECKIN_FILE_CONTENT">
</cfexecute>

But are running into an issue where a user's primary unix group is set to a different group than the VOB the user is trying to check the file into.

I need to run a newgrp command right before executing the #KSH_FILE#

I was sure this would work:

<cfexecute name="C:\cygwin64\bin\rsh.exe"
    arguments="-n -l #USERNAME# #SERVER# ""newgrp #GROUP#; cleartool setview -exec '#KSH_FILE# -user #USERNAME# -dir #VOB_DIRECTORY#' #CLEARCASE_VIEW#"" "
    timeout="180"
    variable="CHECKIN_FILE_CONTENT">
</cfexecute>

But it keeps timing out.. no errors, just spins and stops.

---UPDATE--- Upon further testing, cfexcute and rsh don't seem to allow multiple commands. Here is a sample test I tried that yielded the same problems:

<cfexecute name="C:\cygwin64\bin\rsh.exe"
    arguments="-n -l #USERNAME# #SERVER# ""newgrp #GROUP#; id -a > results.txt"" "
    timeout="180">
</cfexecute>
Klog
  • 109
  • 1
  • 7
  • The solution I am currently working adds the newgrp command to the '#KSH_FILE#'. If anyone has any more advice on why multiple commands are not executable in a cfexecute command I would love to hear it. – Klog Sep 30 '15 at 16:40

2 Answers2

3

I ended up creating a launchcheckin.ksh script to change the user's group within the shell. I just pass the commands that I wanted to execute as arguments to the script, change the group in the script and execute the commands in the newgrp stream! We've had this out in production for 6 months without a hitch.

launchcheckin.ksh

FILE="$1"
GROUP="$2"
COUNT=1
for argument in $*
  do
    if [ ${COUNT} -gt 2 ]
      then
        ARGUMENTS="${ARGUMENTS} ${argument}"
      fi
    ((COUNT+=1))
done

newgrp ${GROUP} << EOF
${FILE} ${ARGUMENTS}
EOF

Updated command

<cfexecute name="C:\cygwin64\bin\rsh.exe"
    arguments="-n -l #USERNAME# #SERVER# ""cleartool setview -exec '/launchcheckin.ksh #KSH_FILE# #GROUP# #ARGUMENTS#' #CLEARCASE_VIEW#"" "
    timeout="180"
    variable="CHECKIN_FILE_CONTENT">
</cfexecute>
Klog
  • 109
  • 1
  • 7
1

Don't use (as I explained here) cleartool setview: it forks the current shell which is why the the newgrp and setview don't communicate well: they trigger their own shells.

If you need to do anything with a dynamic view, use its full path (/view/<aview>/vobs/<avob>), don't use setview. That way, you can use newgrp if you need to.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • VonC, thank you I didn't consider that the commands would be executed in different shells. Do you have an example command I could use instead of setview? – Klog Sep 26 '15 at 16:36
  • @Klog simply use the command you want, but in the full path of the dynamic view: `/view/myView/vobs/myvob/...` (instead of `/vobs/myvob`, as set by the `setview` command) – VonC Sep 26 '15 at 16:37
  • After talking with our ClearCase guru, this solution will not work for us. – Klog Sep 29 '15 at 18:51
  • @Klog OK. Is there any reason which was mentioned? – VonC Sep 29 '15 at 19:23
  • Sorry, they didn't give me any details :/ – Klog Sep 30 '15 at 16:44