I tried to do that :
a = `gdb -q ./test` ; print a
But it's showing nothing, even the gdb process are running. How can I do it ?
gdb waits for some command after start entered from stdin. At least, r to run program. So you need to send r to gdb. Try this:
a = `echo 'r'|gdb -q ./test`; print a
Also, you can read this question