Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script for Windows users #21

Closed
davsclaus opened this issue Jan 8, 2017 · 6 comments
Closed

Script for Windows users #21

davsclaus opened this issue Jan 8, 2017 · 6 comments

Comments

@davsclaus
Copy link
Contributor

Any windows users out there whom want to contribute.

We are looking for a windows version of this script
https://github.com/camelinaction/camelinaction2/blob/master/chapter7/prototype2/rules2-springboot-hystrixdashboard/hitme.sh

as a hitme.bat file that does the same

@kevinearls
Copy link
Contributor

I can do this. Can we assume people have curl from cygwin, should we tell them to install that or get curl from https://curl.haxx.se/download.html, or should I use the powershell equivalent?

@davsclaus
Copy link
Contributor Author

Oh I was thinking a regular bat script? Isnt it possible to do a loop in a batch script?

@kevinearls
Copy link
Contributor

Right. I'll do a bit more research, but so far what I've found says that the best way to do a while loop in a bat script is by using a goto. So that part looks easy.

The hitme.sh script uses the curl command though, which is not on windows by default. So that's what I'm wondering how to replace.

@davsclaus
Copy link
Contributor Author

Ah yeah not even sure if there is something as a http client on windows. We could also just tell people to open a web browser and hit refresh manually if they are on windows

@pedrojuk
Copy link

pedrojuk commented Jun 2, 2018

You can do it with Powershell. Here's a little file that you can save as hitme.ps1 that works:

# hitme.ps1
# replicates what hitme.sh does, but for Windows Powershell
# 
# Open a Powershell window, change to the directory where the script is
# and enter .\hitme.ps1
#
# Type ctrl-C to stop
#
while ($true)
{
  Start-Sleep -m 100
  Write-Host "`n"
#  Invoke-WebRequest "http://localhost:8181/api/rules/999" # full response
  (Invoke-WebRequest "http://localhost:8181/api/rules/999").Content # just the body
# (Invoke-WebRequest "http://localhost:8181/api/rules/999").Content | ConvertFrom-Json | ConvertTo-Json # body, pretty
}

Uncomment the version of the Invoke-WebRequest line you want. The one that's presently uncommented just returns the unformatted JSON response body.

@toindev
Copy link

toindev commented Sep 6, 2018

@pedrojuk My vote goes to PowerShell as well, even if I do have curl installed, this is the most standard Windows way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants