cvscshsungridenginersh

How to write a CVS wrapper script


I'd like to write a CVS wrapper script that executes the command on another machine using RSH but am having trouble with quotes.

#!/bin/csh -f
rsh <machine> cvs $*:q

The problem is that even though the arguments are passed with quotes RSH seems to drop them when the command is executed. The following command should appear as 3 arguments at the destination but has 4 instead.

cvsWrap diff -D "2011-05-01 00:00:00"

I'm not looking for advice on how not to use rsh since I'm really using qrsh, an rsh-compatible version for SGE. I considered using an interpreter but I don't know how to escape the quotes within strings:

rsh <machine> /bin/csh -c "cvs $*:q"

I'm most familiar with c-shell but would be willing to consider a bash script if someone were to write it. How can I write this CVS script?


Solution

  • I declared defeat and just wrote the script in Groovy.

    #!/usr/bin/env groovy
    def rshCmd = "qrsh -cwd -now n -b y".split().toList()
    def cvsCmd = ["cvs"] + args.collect { '"' + it + '"' }
    def process = (qrshCmd + cvsCmd).execute()
    
    def outTh = Thread.start {
      try {
        process.in.eachLine {
          System.out.println it
        }
      } catch(e) {}
    }
    
    def errTh = Thread.start {
      try {
        process.err.eachLine {
          System.err.println it
        }
      } catch(e) {}
    }
    
    outTh.join()
    errTh.join()
    process.waitFor()
    System.exit(process.exitValue())