exec.Command with input redirection
<p>I'm trying to run a fairly simple bash command from my Go code.  My program writes out an IPTables config file and I need to issue a command to make IPTables refresh from this config.  This is very straightforward at the commandline:</p>

<p><code>/sbin/iptables-restore &lt; /etc/iptables.conf</code></p>

<p>However, I can't for the life of me figure out how to issue this command with exec.Command().  I tried a few things to accomplish this:</p>

<pre><code>cmd := exec.Command("/sbin/iptables-restore", "&lt;", "/etc/iptables.conf")
// And also
cmd := exec.Command("/sbin/iptables-restore", "&lt; /etc/iptables.conf")
</code></pre>

<p>No surprise, neither of those worked.  I also tried to feed the filename into the command by piping in the file name to stdin:</p>

<pre><code>cmd := exec.Command("/sbin/iptables-restore")
stdin, err := cmd.StdinPipe()
if err != nil {
    log.Fatal(err)
}

err = cmd.Start()
if err != nil {
    log.Fatal(err)
}

io.WriteString(stdin, "/etc/iptables.conf")
</code></pre>

<p>That doesn't work either, no surprise.  I <em>can</em> use stdin to pipe in the contents of the file, but this seems silly when I can just tell iptables-restore what data to go read.  So how might I get Go to run the command <code>/sbin/iptables-restore &lt; /etc/iptables.conf</code>?</p>