# Inspec on MySQL

**URL:** <https://discourse.chef.io/t/inspec-on-mysql/13004>\
**Category:** Chef InSpec\
**Created:** [May 3, 2018, 1:44pm UTC](https://discourse.chef.io/t/inspec-on-mysql/13004 "2018-05-03T13:44:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wolfyy6](https://avatars.discourse-cdn.com/v4/letter/w/848f3c/32.png) [@wolfyy6](https://discourse.chef.io/u/wolfyy6)\
**Post date:** [May 3, 2018, 1:44pm UTC](https://discourse.chef.io/t/inspec-on-mysql/13004/1 "2018-05-03T13:44:40Z")

</div>

Hi,  
I'm developing anInSpec control that runs CIS compliance commands. While working on MySQL I'm stuck here :

Execute the following SQL statement to determine the Value of datadir :

> show variables where variable\_name = 'datadir';

I need to extract the output from the above command and reuse it in the next command :

> ls -l /.. | egrep "^d[r|w|x]{3}------\s\*.\s_mysql\s_mysql\s\*\d\*.\*mysql"

Theproblem is that the first command is an SQL Request and the second command is a terminal command.

How can I put both of them, (after getting the output of the first command and put it in the second one), in an InSpec control like the following :

> control "mysql1" do  
> impact 1.0  
> title "Use dedicated Least Privileged Account for MySQL Daemon/Service"  
> desc "May reduce the impact of a MySQL-born vulnerability"  
> describe command ('ps -ef |e grep "^mysql.\*$"') do  
> its('stdout') { should match ''}  
> end  
> end
