Can Mercurial print command success messages instead of no response in the output prompt?
It returns a value, hence you can wrap it around a script.
you could writepost-<command>hooks to output whatever you want on succesful commands. I don't see what the benefit would be however.
the book has a tutorial on hooks doing almost exactly what you want but with commit
. note with a post-command hook you shouldn't need to check the result for success as the hook will only be run if the command was successful.
Related
At work we use telnet to directly connect to embedded devices on our network to issue REST API calls to the device during testing and setup. We later use those calls when developing a web interface.
I like my history and cursor control in the shell, so I use rlwrap with telnet and that works great.
One personally annoying thing is that when I do an API call, like a GET, I 'get' back the data I want in a raw single-line format.
Example:
GET /tw/info
{"result":{"fault":0,"cps":2,"currentLoad":5,"lineVoltage":42176,"temperature":39,"voltage":42524,"current":53,"state":2}}
This is fine for short outputs, but when it gets to be 5-6 lines long or more it would be nice to have it pretty-printed for readability's sake.
Nothing fancy, just basic indenting would do, like:
GET /tw/info
{
"result":
{
"fault":0,
"cps":2,
"currentLoad":5,
"lineVoltage":42176,
"temperature":39,
"voltage":42524,
"current":53,
"state":2
}
}
Are there any known tricks, options, or plugins for telnet/rlwrap to achieve this? Or perhaps I missed a specialized telnet client somewhere? Or will I need to go the software-route and do something like use python and readline to suck out the output and format it in the host shell?
Any tips or hints to point me in the right direction are appreciated.
ADDENDUM: While I accepted knittl's answer as my chosen 'correct' answer - it is the right answer as far I can see - what I did not stress is that this needs to work in an interactive telnet session. jq does not play nice with telnet, as noted in the comments - unless someone would like to prove me wrong. But should work for just about any other situation where output is immediately returned from a program/script.
There are many tools to format and pretty-print JSON. One such tool is jq with many questions and answers here on StackOverflow.
It consumes one or more JSON documents via stdin and formats those according to a filter. The simplest filter is . and recent jq versions will default to this filter if none is specified.
program | ./jq '.'
Note that GET /path/file is not a valid REST GET request, because it is missing the protocol version (HTTP/1.x) and the Host header for version 1.1.
For how to link this to an interactive telnet session: I don't know. Python is probably a sensible route as you have already suggested.
So exclude first line when passing to jq.
program | { read line; echo "$line"; jq '.'; }
After i pass issue by modify condition in "while" in Jmeter - Stop reading CSV file after find out right item
Now i want to run "http request" one time only when i find out right product. Currently, number of "http request" is equal number of loop in while.
How can i run HTTP request one time?
not sure if I understand your question correctly but would not https://jmeter.apache.org/usermanual/component_reference.html#Once_Only_Controller help?
It is triggered only once per each thread. Usually used for logins.
I used "IF controller" in "While Controller" and resolve this issue.
While ("${Error}"=="Response Error")
CSV file (brandid,brandurl,producturl)
if ("${brandOfWH}"=="${brandid}")
-- Http request
-- -- BSF Preprocessor
-- -- Get "Error" extractor
I've been using the new commandline for Postman, Newman, and have been attempting to run Collection tests that work fine when I pass them through the packaged app Jetpacks add-on, but do not run properly in the commandline. Although the json Collection file that I am passing does contain the proper header declarations, I don't have any other clues at this point, so I suspect that this may be an HTTP header issue. But I am not sure exactly what is wrong, as I am rather new to using Postman.
The tests that I'm trying to run are on some calls to an ASP.Net web API, very simple server response-checking one-line javascript tests like the ones in this tutorial.
A sample line that I enter into the console:
$ newman -c collectionfile.json -e environmentfile.json -n 5
achieves such a result:
RequestError: [token] terminated. Error: undefined
Any suggestions/help would be appreciated.
I ran into this problem as well and spent quite a few hours trying to figure it out. Eventually I realized that an address such as "www.google.com" will work in the chrome plugin UI, but not in Newman. For it to work in Newman, the address must be "https://www.google.com". Also, make sure that you have your data file (if you are using variables like {{url}}) set up correctly. You can use "-d dataFile.json" to define a data file. More information on that here.
It is merely a childish question, but I have stuck upon an HTTP POST request through putty command line. After performing the initial request:
~$ POST <url:port/directory>
Please enter content (application/x-www-form-urlencoded) to be POSTed:
...(content posted there)
I have no option to send the command, since the only keyboard sequence working is CTRL-Z, which stops the procedure, other than sending the command. Is there any other interaction for the END-OF-FILE?
CTRL-D will simulate EOF. You can also pipe into POST, which may make things easier for testing, for example:
cat ~/my-json-file.json | POST <url:port/directory>
I run into a question that asked by a flex interviewer:
If there are 2 requests from the command class, and when back end process the request, they may take different time(the first command may take longer time to process so that it returns after the response of the second request).so, in your result-handler of your how do you know which response is for which request?
Note: they are in the same command, and they are processed by the same result handler.