Ask Your Question
0

Can somebody explain the command in below code?

asked 2016-09-28 02:58:39 -0500

abhishekb gravatar image

updated 2016-09-28 03:00:29 -0500

exec {'anything.bat' : command => "C:\windows\system32\cmd.exe /c cd C:\windows\automation\puppet\ && anything.bat", }

What the bold part in above code doing ??

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2016-09-28 05:04:51 -0500

dancewind gravatar image

Change to the directory "C:\windows\automation\puppet\" and if change successfully then execute anything.bat.

edit flag offensive delete link more
0

answered 2016-09-28 08:24:47 -0500

DarylW gravatar image

updated 2016-09-28 08:27:33 -0500

the anything.bat script needs to run in a specific directory. The above exec is chaining together two commands, one command to change directory, and the other command to execute the .bat.

The user would be better served to use the exec resource's cwd (Command Working Directory) parameter instead.

https://docs.puppet.com/puppet/latest...

cwd

The directory from which to run the command. If this directory does not exist, the command will fail.

Like the following

exec {'anything.bat' :
 command => "C:\windows\system32\cmd.exe /c C:\windows\automation\puppet\anything.bat", 
  cwd => "C:\windows\automation\puppet\",
}
  • Note - I don't know enough about puppet on windows to know if the explicit cmd.exe is required, you may be sufficient to only provide the path to the batfile for the command, and use the cwd parameter.
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-09-28 02:58:39 -0500

Seen: 45 times

Last updated: Sep 28 '16