Ask Your Question
1

Exec Command Quoting (Windows)

asked 2013-07-15 14:13:35 -0500

louis gravatar image

updated 2013-07-21 19:25:39 -0500

Hi,

I am trying to generate a known_host file on a windows host with the following resource...

$gitpath = 'C:\Program Files (x86)\Git\bin'

  exec {'known_hosts':
    creates   => 'C:\Users\${user}\.ssh\known_hosts',
    command   => 'cmd.exe /k "${gitpath}\ssh-keyscan.exe -t rsa "github.com" > C:\Users\${user}\.ssh\known_hosts"',
    logoutput => true
  }

I was having an issue with the quoting of the Program Files path so i changed to a variable but still fails. I had to use cmd.exe since i want to save the output to a file on a specific path.

edit retag flag offensive close merge delete

Comments

Can you post the error output here as well?

GregLarkin gravatar imageGregLarkin ( 2013-07-16 08:42:05 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2013-07-30 09:21:27 -0500

louis gravatar image

Hi,

I fixed the issue by using the following resource...

 exec {'known_hosts':
    creates   => 'C:\Users\userid\.ssh\known_hosts',
    command   => 'cmd.exe /k "ssh-keyscan.exe -t rsa myhosturl > C:\Users\userid\.ssh\known_hosts"',
    cwd       => "${gitpath}", 
    logoutput => true
  }

The issue was that the original was not using double quotes and i was using a variable inside. Now the variable goes into the cwd attribute and now i can use single quotes again.

edit flag offensive delete link more
0

answered 2013-07-23 10:54:36 -0500

GregLarkin gravatar image

What happens if you remove the double-quotes from around github.com? Are they necessary? Also, check how quoting works in Puppet and perhaps escaping some of the quotes will solve the issue.

If you have any specific error messages, please post them here for further troubleshooting.

edit flag offensive delete link more

Comments

I did originally, but askpuppet site adds an html a tag around it. Skip the double quotes :)

louis gravatar imagelouis ( 2013-07-23 14:01:31 -0500 )edit

Ok, but do you have any error messages that you can post that would help troubleshoot the problem?

GregLarkin gravatar imageGregLarkin ( 2013-07-23 16:59:35 -0500 )edit

Did you finally get this working? If so, how did you do it?

GregLarkin gravatar imageGregLarkin ( 2013-07-29 13:16:31 -0500 )edit

will try today. I think i am going to use **cwd** and use double quotes since i am using a variable there. will post my results later.

louis gravatar imagelouis ( 2013-07-29 14:25:25 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-07-15 14:13:35 -0500

Seen: 1,591 times

Last updated: Jul 30 '13