Checking DNS records of a specific nameserver

I’m migrating a site from GoDaddy to HostGator (I personally would prefer to move over AWS but that’s the client’s choice in this specific case) and I wanted to get the IP of the new server on HostGator. I couldn’t find the IP anywhere on their control panel. Pinging the temporary URL they provide for testing was returning a different address — I suspect they have some kind of proxy in place for this temp URLs.

I know the host command could give me the DNS settings, which would include the A record with the IP address. However, the domain was still set to use GoDaddy’s nameservers (NS). Running host "name.tld" would give me the DNS records from GoDaddy. However, I was wondering if I could run the command against a specific nameserver. It makes sense having a way to look for records that way, right?

Looking at the man page for host command, there is a server argument. The signature looks like host [options] host [server]. So, I ended up running:

host -a "name.tld" "new.nameserver.tld"

And, voilà! I got the IP address for the new web server.

Got questions? Feel free to comment below.


Usando os comandos do Symfony2 isolados

Um componente muito útil do Symfony2 é o Console. Ele permite a criação de comandos que podem ser executados via terminal. Isso é muito útil para processos relacionados à manutenção do sistema e àqueles que devem estar na crontab, por exemplo. Assim como os demais componentes do framework, o Console pode ser usado isolado e isso é muito interessante para quando é necessário fazer uma aplicação que deve ser executada via linha de comando.

Para facilitar a criação de um aplicação baseada nesse componente, criei um projeto base no GitHub: No README existem algumas instruções de como executar e customizar o código, mas ele basicamente adiciona, além do próprio Console, o registro automático de comandos dentro de um namespace específico através do componente Finder, também do Symfony2.

Declarando arrays em shell script, no bash

Apenas uma referência básica de declaração de arrays em shell script, no bash. Em relação ao uso, existem várias formas e possibilidades.

Exemplo com strings:

nomes=( "Esse" "Aquele" "Outro" )

Exemplo com inteiros:

ids=( 1 2 3 4 5 6 7 )

Recursive chmod

Sometimes you need to change the access control to files matching some requirement. E.g. today I needed grant execute access to the owner of all PHP scripts running under Apache HTTP Server, in a specific directory.

Continue reading “Recursive chmod”

Writing an init script for a Java application

UPDATE, Oct, 1st 2014

This is an old post (from 5 years ago when I writing this update) and the solution isn’t the best. So take a look at the comments – specially that one by Tinoco.

The need make us study topics we think we’ll never need. Today I had to write a simple bash program to start (and stop) a Java application, a simple init script.

After much searching, I’ve found some simple explanations for some specific points of the bash script syntax.

I don’t know who is on the right side of this story, but seems that professionals who write manuals and tutorials for this language doesn’t think like common web programmers, such as Java or PHP programmers. I sought to much on Google to find things like how I could associate the returning value of a function to a variable.

But finally, I’ll leave aside the claims and move to example:

Continue reading “Writing an init script for a Java application”