1

I am execution a wget command inside my groovy code, the command is like this:

cmd /c C:/wget.exe -q -O - <my-URL>

When i actually run this command from cmd or windows run util, it works fine. But when i try to run this from within my groovy code, I don't see the output. How can i capture the output of this within groovy.

Thanks!

user620339
  • 851
  • 3
  • 20
  • 42

2 Answers2

6

Instead of using wget why not just use groovy to get you the content:

def data = new URL(myUrl).getText()
dstarh
  • 4,976
  • 5
  • 36
  • 68
  • But im getting below error while running above command for HTTPS URL - 20:01:55 at hudson.model.ResourceController.execute(ResourceController.java:99) 20:01:55 at hudson.model.Executor.run(Executor.java:432) 20:01:55 Caused by: java.net.ConnectException: Connection refused (Connection refused) 20:01:55 at java.base/java.net.PlainSocketImpl.socketConnect(Native Method) 20:01:55 at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399) 20:01:55 at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.j – Rahul kuchhadia Oct 01 '21 at 14:36
6
"cmd /c C:/wget.exe -q -O - <my-URL>".execute().text

But new URL("<my-URL").text might be a better way to load an url without relying on wget.

ataylor
  • 64,891
  • 24
  • 161
  • 189