Unable to get Google definitions to Standard Output - filter

I aim to filter my Google results right at terminal such that I get only Google's definitions.
I am trying to run the following in Mac's terminal
open http://www.google.com/search?q=define:cars&ie=utf-8&oe=utf-8:en-GB:official&client=vim
A similar command for Firefox is
open http://www.google.com/search?q=define:cars&ie=utf-8&oe=utf-8:en-GB:official&client=firefox-a
Which client can you use to have Google's html page to your standard output?

To use Google search not through their web interface, you're almost certainly better off using their API.
However, I think curl is the right tool to use to download a web page if that's what you have to do (and it probably isn't)

"GET"
GET 'http://www.google.com/search?q=define:cars&ie=utf-8&oe=utf-8:en-GB:official&client=vim'
See also "HEAD".
The command can be installable on Gnu/Linux OS:
[elcuco#pinky ~]$ rpm -qf `which GET`
perl-libwww-perl-5.808-2mdv2008.1
In theory you could also use "wget" and output to stdout using something like this:
wget http://www.google.com -O - --quiet
However I cannot get it to work with this example URL.

Related

Running command with /dev/null on Windows

OK, this question has been asked before (e.g. Is there a /dev/null on Windows?) but I'm trying to find an answer that works, and all of the prior questions just say "change the command to point to NUL"
If I have a curl request (or whatever) which someone ran on a Unix/Mac which includes this:
-o /dev/null
it will throw an error if I try to run it as-is on my Windows box. Therefore, I need to change the command by replacing that with:
-o NUL
My question is, is there something I can do so that I can run the original curl request without needing to make that change?
IOW, can I create a symlink or something similar, so that I don't need to change the curl statement? Basically so I can use the *nix syntax on a Windows box?
Before someone says "how much hassle is it to change the curl", I'm running hundreds of curls a day, often ones which were originally run on a *nix box. Also, if I change to use Windows syntax, then when someone tries to run it on a *nix box, they get issues....

xdg-settings not setting default-web-browser in gentoo

I'm trying to get xdg-open to using chromium to open urls instead of firefox. I noticed that xdg-settings get default-web-browser returns chromium.desktop when it should be chromium-browser-chromium.desktop.
Following the instructions here I tried xdg-settings set default-web-browser chromium-browser-chromium.desktop, which runs with no errors. However when I run xdg-settings get default-web-browser it stills shows chromium.desktop, and xdg-open "http://www.example.com" still uses firefox. I have confirmed that /usr/share/applications/chromium-browser-chromium.desktop is present. Rebooting the machine does not fix the problem.
For now, I've created a "chromium.desktop" sym-link to "chromium-browser-chromium.desktop", but it would be nice to know why xdg-settings is not working.
xdg-* utilities are just quite simple POSIX shell scripts that try their best to handle simple common DE tasks in a seemingly standardized way. But the truth is, that every DE uses its own tools and knobs, and every installation uses different mix of them, so in this case it seems that you're using some non-standard desktop environment, which these poor utilities just cannot handle.
Anyway, if you want to debug your specific issue, run those scripts with sh -vx (eg. sh -vx /usr/bin/xdg-settings) and it will tell you exactly what those scripts are doing and at which point they fail.

using ctags or cscope(without interactive mode) from commandline

I am using a custom editor for an embedded systems project. For source code I would like to get ctags working from command line and give me search results on commandline. Other option is to work with cscope in non interactive mode so I can include it in my editor at a later date. I did some initial web search but couldn't find anything relevant to accomplish this.
Does anyone know how to use either of these tools from command line?? Any tutorial?
Thanks.
Have a great day.
Using readtags.c shipped as part of ctags implementation, you can search a tag from given tags file.
Let me show an example:
$ ctags -R main
$ readtags -t tags kindDefinition
kindDefinition main/types.h /^typedef struct sKindDefinition kindDefinition;$/
$ readtags -t tags -e kindDefinition
kindDefinition main/types.h /^typedef struct sKindDefinition kindDefinition;$/;" kind:t typeref:struct:sKindDefinition

Elastic Search: Make pretty format as the default

Is there a way to make the JSON output of curl commands Pretty printed by default? That is, without specifying the option of ?pretty=true to the curl URL, is it possible to display the output pretty printed everytime?
I was able to accomplish this by adding a new alias to my .bashrc (or .bash_profile on a mac):
alias pp='python -mjson.tool'
Then, after reloading the .bashrc / .bash_profile configuration by opening a new terminal or by running
$ source ~/.bashrc
you can pipe curl output to the 'pp' alias as follows:
$ curl -XGET http://localhost:9200/_search | pp
Source: http://ruslanspivak.com/2010/10/12/pretty-print-json-from-the-command-line/
ElasticSearch has no such permanent setting and I don't want such. Quite often I see that developers forget to undo such settings in production and then overall product performance is degraded. Similar example is leaving DEBUG logging enabled which is very popular performance killer.
You have plenty of tools to ease your development:
RestClient‎ Firefox plugin
[ElasticSearch Head] - excellent ES admin which even pretty formats your input
plus earlier mentioned ElasticShell.
However if you really really want to make it in curl here is simple trick I've just made. Run this in your bash shell or script:
curl() { `which curl` $# | python -mjson.tool ; }
And you use curl as before:
curl http://localhost:9200/
To undo:
unset -f curl
Of course it would be better to name the function as ppcurl if you don't like above :)
In most cases, you use REST API from other products (JQuery, PHP, Perl, Ruby...). These frameworks don't need to have pretty input.
So, I assume that in 99% of the requests you don't want to slow your requests by pretty rendering JSON.
IMHO, you only need pretty print when doing debug or in dev mode.
An option could be to have it as an elasticsearch property in elasticsearch.yml file. Open an issue for it?
You can easily use jq instead:
curl --location --request GET 'http://localhost:9200/_cluster/health' | jq .

LYNX like command in DOS?

Is there any "lynx" like command DOS?
I want to get list of all files in a website.
I searched Google for "lynx dos" and found this: http://www.fdisk.com/doslynx/lynxport.htm
there is lynx for dos: http://www.rahul.net/dkaufman/lynx2.8.5rel.1-DOSc.zip (from http://www.rahul.net/dkaufman/)
there is also wget and curl builds for dos (links on the site above) which you can try out
No, there is not.
telnet would be the closest, but it's very different :)

Resources