9

ab -n 1 -c 1 http://localhost:2020/welTo.do?pxtId=3000007937&superDo=jack

I got answer for first query string but i also get

'superDo' is not recognized as an internal or external command, operable program or batch file.

Please help me

TIA

Regards thiru

skaffman
  • 398,947
  • 96
  • 818
  • 769
thirumalairaj
  • 91
  • 1
  • 1
  • 2

3 Answers3

20

You probably just need to quote the URL to avoid shell special characters from being interpreted. In this case your & symbol is causing the text to the left to be run in the background while attempting to run superDo as a command.

 ab -n 1 -c 1 'http://localhost:2020/welTo.do?pxtId=3000007937&superDo=jack'
noodl
  • 17,143
  • 3
  • 57
  • 55
  • Worked, but (at least on windows) I needed to use double-quotes (`"`) – thaddeusmt Feb 10 '12 at 15:48
  • If you get something like `apr_sockaddr_info_get() for localhost: no such host is known` then use IP `127.0.0.1` rather than `localhost`. – lubosdz Apr 11 '23 at 21:29
6

There are two workarounds for this:

  1. You can use double quote to surround the url:

ab -n 1 -c 1 "http://localhost:2020/welTo.do?pxtId=3000007937&superDo=jack"

  1. Escape "&" with a backslash:

ab -n 1 -c 1 http://localhost:2020/welTo.do?pxtId=3000007937\&superDo=jack

Thomas Bormans
  • 5,156
  • 6
  • 34
  • 51
user551168
  • 599
  • 5
  • 2
3

Have you tried the post file? think this should work:

ab -n 1 -c 1 -p postfile.txt -T 'application/x-www-form-urlencoded' http://localhost:2020/welTo.do

And then make a flat file named postfile.txt with contents like this:

pxtId=3000007937&superDo=jack

Example adapted from here

Purefan
  • 1,498
  • 24
  • 44
  • Hey is it possible to specify the post data within the command itself instead of the file just like in curl? – David Okwii Apr 02 '17 at 17:54
  • According to the docs this option isn't available, but you can create a named pipe and read from it, which is pretty much as storing the contents in a file. Any reason why you cant use a traditional file? – Purefan Apr 03 '17 at 06:57
  • It's more convenient to specify the params in the command especially when they are few. And since curl and other tools do it, I expected ab to do the same. Otherwise am not exactly sure how to "create a named pipe and read from it". – David Okwii Apr 04 '17 at 09:10
  • @DavidOkwii This explains it pretty well http://stackoverflow.com/a/6675168/363217 – Purefan Apr 04 '17 at 10:08