8

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
  • 390,936
  • 96
  • 800
  • 764
thirumalairaj
  • 81
  • 1
  • 1
  • 2

3 Answers3

19

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
  • 16,927
  • 3
  • 55
  • 55
5

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
  • 4,896
  • 6
  • 33
  • 48
user551168
  • 499
  • 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,438
  • 23
  • 42
  • 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