Arguments with exec.Command


(rich) #1

Hi all,

New to code and trying to learn Go as a first language. Is it possible to use multi-line arguments with exec.Command?

I am trying to send the following command:

FastCli -p 15 -c ' enable config interface et1 description test'

With each item inside the single quote being its own line.

Thanks for any insight that you can offer.

Regards,

Rich


(Norbert Melzer) #2

Yes you can. You need to translate your shells quoting and escaping rules into go’s and just prepare and run the command.

As I’m on mobile now, I can’t do so for you. But it’s usually trivial to do so.


(rich) #3

Thx Nobbz,

I was able to get it to work with the following:

cmd := exec.Command("/usr/bin/FastCli", "-p15", "-c\r\nenable\r\nconfig\r\nip route 2.2.2.2/32 10.255.255.255\r\n")


(system) closed #4

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.