# scp fails in post build command

**URL:** https://discourse.cmake.org/t/scp-fails-in-post-build-command/4795
**Category:** Usage
**Created:** [January 7, 2022, 12:44pm UTC](https://discourse.cmake.org/t/scp-fails-in-post-build-command/4795 "2022-01-07T12:44:15Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![DavidA](https://discourse.cmake.org/user_avatar/discourse.cmake.org/davida/32/128_2.png) [@DavidA](https://discourse.cmake.org/u/DavidA)
#### Post date: [January 7, 2022, 12:44pm UTC](https://discourse.cmake.org/t/scp-fails-in-post-build-command/4795/1 "2022-01-07T12:44:16Z")

</div>

I’m running cmake 3.20.2 on Windows 10 and trying to call scp to copy an artefact to a remote machine after a successful build:

```auto
add_custom_command(
    TARGET wdt_interrupt_gnu
    POST_BUILD
    COMMAND ${CMAKE_OBJCOPY} -O verilog $<TARGET_FILE:wdt_interrupt_gnu>  
            ${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_NAME:wdt_interrupt_gnu>.vlg
    COMMAND scp.exe ${CMAKE_CURRENT_BINARY_DIR}/wdt_interrupt_gnu.vlg <user name>@<remote path>
  )

```

When running make that step fails:

```auto
process_begin: CreateProcess(NULL, scp.exe C:/<snip>/build/wdt_interrupt_gnu.vlg <user name>@<remote path>, ...) failed.
make (e=2): The system cannot find the file specified.
make[2]: *** [wdt_interrupt_gnu.axf] Error 2
make[2]: *** Deleting file `wdt_interrupt_gnu.axf'
make[1]: *** [CMakeFiles/wdt_interrupt_gnu.dir/all] Error 2
make: *** [all] Error 2

```

Any suggestions how to fix this please?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [January 7, 2022, 1:17pm UTC](https://discourse.cmake.org/t/scp-fails-in-post-build-command/4795/2 "2022-01-07T13:17:51Z")

</div>

It looks like `scp` is not available in `PATH`. Can you use a full path to the binary instead (maybe with `find_program`)?

---

<div class="post-metadata">

### Author: ![DavidA](https://discourse.cmake.org/user_avatar/discourse.cmake.org/davida/32/128_2.png) [@DavidA](https://discourse.cmake.org/u/DavidA)
#### Post date: [January 7, 2022, 1:58pm UTC](https://discourse.cmake.org/t/scp-fails-in-post-build-command/4795/3 "2022-01-07T13:58:44Z")

</div>

@ben.boeckel Thanks, but with path provided by find\_program I get a similar error:

`process_begin: CreateProcess(NULL, C:/Windows/System32/OpenSSH/scp.exe C:/SVNProj/Elysion/trunk/software/prototypes/wdt_interrupt_gnu/build/wdt_interrupt_gnu.vlg <user name>@<remote path>, ...) failed.`

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [January 7, 2022, 2:02pm UTC](https://discourse.cmake.org/t/scp-fails-in-post-build-command/4795/4 "2022-01-07T14:02:05Z")

</div>

Hmm. I think figuring out what “the file specified” being referred to here is would be the next step. You can use [Process Monitor](https://docs.microsoft.com/en-us/sysinternals/downloads/procmon) to do this (though it isn’t trivial, there are blogs about how to use it).
