Search Results

Search found 1 results on 1 pages for 'alidad'.

Page 1/1 | 1 

  • Bypassing confirmation prompt of an external process

    - by Alidad
    How can I convert this Perl code to Groovy? How to bypass confirmation prompts of an external process? I am trying to convert a Perl script to Groovy. The program is loading/delete maestro (job scheduling) jobs automatically. The problem is the delete command will prompt for confirmation (Y/N) on every single job that it finds. I tried the process execute in groovy but will stop at the prompts. The Perl script is writing bunch of Ys to the stream and print it to the handler( if I understood it correctly) to avoid stopping. I am wondering how to do the same thing in Groovy ? Or any other approach to execute a command and somehow write Y on every confirmation prompt. Perl Script: $maestrostring=""; while ($x < 1500) { $maestrostring .= "y\n"; $x++; } # delete the jobs open(MAESTRO_CMD, "|ssh mserver /bin/composer delete job=pserver#APPA@") print MAESTRO_CMD $maestrostring; close(MAESTRO_CMD); This is my groovy code so far: def deleteMaestroJobs (){ ... def commandSched ="ssh $maestro_server /bin/composer delete sched=$primary_server#$app_acronym$app_level@" def commandJobs ="ssh $maestro_server /bin/composer delete job=$primary_server#$app_acronym$app_level@" try { executeCommand commandJobs } catch (Exception ex ){ throw new Exception("Error executing the Maestro Composer [DELETE]") } try { executeCommand commandSched } catch (Exception ex ){ throw new Exception("Error executing the Maestro Composer [DELETE]") } } def executeCommand(command){ def process = command.execute() process.withWriter { writer -> 1500.times {writer.println 'Y' } } process.consumeProcessOutput(System.out, System.err) process.waitFor() }

    Read the article

1