Nslookup in Bash Script
<p>How can I get result of a dns mx record with <code>nslookup</code> in a <code>.sh</code> file that it would do all its steps automatically without questioning <code>set type=mx</code> then domain. I just want execute <code>./file.sh</code> then it give me the result.</p>

<p>The bash file might be something like this:</p>

<pre><code>#!/bin/bash
nslookup
set type=mx
example.com
</code></pre>

<p>But everytime I execute the file it just runs the first line <code>nslookup</code>, and it requests <code>set type=mx</code> and domain again.</p>

<p>I got my answer in stackoverflow in another way with using <code>-q=mx</code>:</p>

<pre><code>#!/bin/bash
nslookup -q=mx example.com
</code></pre>

<p>But I would like my answer to use <code>set type=mx</code></p>