Automate scanning bash script

Hello everyone, everything good?

I need to automate my scanning using bash script with gvm-cli. For example, today I run gvm-cli commands individually, but it is becoming laborious. For example, I use the command “gvm-cli socket --xml <create_target>” to create the hosts and receive the id. Then I take the id and put it in the command “gvm-cli socket --xml <create_task>” to create the tasks and so on. As I’m resuming my studies with bash and I’m having some difficulty, could anyone help me? How can I get the id from the first command, put it in a variable and use it in the second command? Remembering that the first command returns a large string, I may need to find the term “id” to copy it.


I strongly suggest using python-gvm to automate rather than using a bash script. I’m sure you will find that python-gvm Python package in tandem with the scripts available from gvm-tools will give you a better starting point for automating GVM tasks.

For example, gvm-tools includes a script to create targets

1 Like