Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6845663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:31:42+00:00 2026-05-27T00:31:42+00:00

How can I convert this Perl code to Groovy? How to bypass confirmation prompts

  • 0

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 working groovy code:

    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 ->
          writer.print('y\n' * 1500)
        }
       process.consumeProcessOutput(System.out, System.err)
       process.waitFor()
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:31:42+00:00Added an answer on May 27, 2026 at 12:31 am

    A direct translation would be:

    'ssh mserver /bin/composer delete job=pserver#APPA@'.execute().withWriter { writer ->
        writer.print('y\n' * 1500)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There's this program, pdftotext, that can convert a pdf file to a text file.
Can somebody advise me what this code does and how can I convert it
I'm trying to convert the following perl code: unpack(.., Z*) to python, however the
How I can convert this code to LINQ? var TcData = new List<double>(); for(int
How can i convert this to a decimal in SQL? Below is the equation
how can i convert this into an array? if someone searches for lo he
How can i convert this $langClarContent = > &# 1059.,&#1095.,&#1080.,&# 1090.,&# 1077.,&# 1083.,Dokeos &#
Can anyone help convert this this actionscript to Objective-c? if(mcMain.y >= stage.stageHeight - mcMain.height)
You can convert a negative number to positive like this: int myInt = System.Math.Abs(-5);
convert this: $300 to this : 300 can't do it with intval() or (int)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.