Skip to content

Instantly share code, notes, and snippets.

@melastmohican
Last active February 12, 2020 08:33
Show Gist options
  • Save melastmohican/a30aa95ae271ef4beea051dead10b766 to your computer and use it in GitHub Desktop.
Save melastmohican/a30aa95ae271ef4beea051dead10b766 to your computer and use it in GitHub Desktop.
Download file using curl in groovy
#!/usr/bin/env groovy
def execute(command) {
def proc = command.execute()
def out = new StringBuffer()
def err = new StringBuffer()
proc.consumeProcessOutput(out, err)
proc.waitFor()
if( out.size() > 0 ) println out
if( err.size() > 0 ) println err
return [ 'out':out.toString(), 'err':err.toString() ]
}
// --max-time <seconds>
def response = execute("curl --max-time 6 --retry 6 -O http://www.scscourt.org/online_services/jury/jury_duty.shtml#tables")
assert response['out'] == ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment