Le 26/07/2017 à 20:10, Nick Couchman a écrit : > Thank you for the suggestion, Mike. > > I've tried it both ways, and neither of them works. In fact, the > "YAML Syntax" doesn't seem to actually attempt to change directory - > if I use that, I get an error along the lines of file not found or > command not found, indicating that it isn't even going to the > directory. If I put it up on the line with win_command, it seems to > actually try to chdir, but fails due to the space. > > I forgot to mention in the original post that I have tried all sorts > of variations of double and single quotes and combinations thereof, > and that hasn't made a difference - however it gets passed in to the > command, it seems like PowerShell ends up interpreting it as > C:\Program and just chopping it off at the space. > > I am able to get a command in a directory to run using PowerShell's > special escape syntax: > & 'C:\Program Files\Application\mycmd.exe' > > But this doesn't seem to work in the chdir argument. Unfortunately > because the application that I'm running relies on the presence of > certain files in the current working directory, I need to actually > move to that directory. > > Thanks, > Nick
I always found a bad idea to put space in files or directory names... but Microsoft did it There should be a mean to escape it correctly... But as a workaround, did you try with the 8.3 dos syntax (I hope the compatibility still exist) ? dir /x will show you what to use... (there's a tilda in the name to use often) Regards, JYL > > On Wednesday, July 26, 2017 at 12:35:59 PM UTC-4, Swedish Mike wrote: > > Nick, > > I saw it mentioned somewhere that if you use 'YAML syntax' with > the :'s instead of Ansibles ='s you should not need escape > characters for directories with spaces in them. Ie, if you do it > like this: > > - win_command: runsomething.exe > args: > chdir: c:\Program Files\Application > > The other thing I can think of is adding single quotes ' around > the path. > > Sadly I don't have any Windows boxes around that I can test this > on right now for you, but it could be worth a try? > > Cheers, Mike > > On Wed, Jul 26, 2017 at 4:17 PM Nick Couchman > <[email protected] <javascript:>> wrote: > > So, I'm trying to run a command via Ansible, and the command > exists in a path that's in a directory with spaces, namely > c:\Program Files. I need the module to chdir to the directory > where the command is actually located because there are files > that it needs to reference inside that directory. > Unfortunately it doesn't seem to want to work, no matter what > I try. I've tried the following variations on the path to > make it work: > C:\Program Files\Application > C:\\Program Files\\Application > C:\\Program\ Files\\Application > C:\\Program^ Files\\Application > C:/Program Files/Application > C:/Program\ Files/Application > > No matter what I try, here, I get the following message from > the module: > > The directory name is invalid > > What's the trick to making chdir work for directories with > spaces?? > > Thanks - Nick > -- > You received this message because you are subscribed to the > Google Groups "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from > it, send an email to [email protected] > <javascript:>. > To post to this group, send email to > [email protected] <javascript:>. > To view this discussion on the web visit > > https://groups.google.com/d/msgid/ansible-project/8581aa1e-4010-4616-b399-771acf2fa96f%40googlegroups.com > > <https://groups.google.com/d/msgid/ansible-project/8581aa1e-4010-4616-b399-771acf2fa96f%40googlegroups.com?utm_medium=email&utm_source=footer>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. > > -- > You received this message because you are subscribed to the Google > Groups "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/15ccacde-3e94-4347-a0f7-d5013bbb6d6f%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/15ccacde-3e94-4347-a0f7-d5013bbb6d6f%40googlegroups.com?utm_medium=email&utm_source=footer>. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/0231b5c9-dd65-8753-b080-2b11a6afa645%40lenhof.eu.org. For more options, visit https://groups.google.com/d/optout.
