Arguments with exec.Command

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

1 Like

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.

2 Likes

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")

2 Likes

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