Karate | String Split for CLI output

Viewed 12

I am trying to get the ip of the machine and pass to the endpoint with the below piece of code and getting the desired value in serviceId parameter.

'''* def output = karate.exec('ipconfig')

  • def serviceId1 = output.split('IPv4 Address. . . . . . . . . . . :')[1]
  • def serviceId = serviceId1.split(' ')[1]
  • print serviceId'''

Is there any other simpler way i can implement this.

0 Answers
Related