File Delete and then Copy

Can someone tell me why this won’t work. The delete works great but the copy of the file failes.

// Enter your action script here
delete "C:\program files\splunkuniversalforwarder\etc\system\local\deploymentclient.conf"
copy “D:\downloads\splunk\deploymentclient.conf” “C:\Program Files\SplunkUniversalForwarder\etc\system\local”

This is a task. The file is located on the bigfix server at “D:\downloads\splunk\deploymentclient.conf” and it is copied to C:\Program Files\SplunkUniversalForwarder\etc\system\local.

The delete works just great, but the copy fails

Thanks

Be sure to have action uses wow64 redirection false in you script somewhere before the copy, else it may be getting redirected to the x86 folder.

And be sure the Splunk Universal Forwarder service is stopped, it may have an open file lock on the config file.

Oh, I believe you may need the filename in the copy target. I haven’t checked the reference, but by convention I always include both the directory and filename in the copy target.

Also, the destination name needs to be the full name, including the file name. Replicating the command line syntax doesn’t work in actionscript

Yeah, I still have the same issue. Delete works, copy does not. I have this now as the action script:

// Enter your action script here
action uses wow64 redirection false
delete "C:\program files\splunkuniversalforwarder\etc\system\local\deploymentclient.conf"
copy “D:\downloads\splunk\deploymentclient.conf” “C:\Program Files\SplunkUniversalForwarder\etc\system\local\deploymentclient.conf”

copy “D:\downloads\splunk\deploymentclient.conf” “C:\Program Files\SplunkUniversalForwarder\etc\system\local\deploymentclient.conf”

Could this possibly be the issue since the task is performed on a remote server? the D: drive is on the bigfix server but the C: drive would be on the target server.

Instead I created a software distribution and changed the necessary info, but it still fails to even delete the file on the server:

Completed prefetch 88f8ec066544b7c6b5ff175d85cf49a32d317dea sha1:88f8ec066544b7c6b5ff175d85cf49a32d317dea size:141 http://BDOWSPBGFX:52311/Uploads/88f8ec066544b7c6b5ff175d85cf49a32d317dea/deploymentclient.conf.tmp sha256:244cd924e7b0df2d8fdfc3475504040bda36b417146e60af204498ff4909327c
Completed extract 88f8ec066544b7c6b5ff175d85cf49a32d317dea

Failed wait __Download\deploymentclient.conf
action uses wow64 redirection false
delete "C:\Program Files\SplunkUniversalForwarder\etc\system\local\authentication.conf"
copy “__Download\deploymentclient.conf” “C:\Program Files\SplunkUniversalForwarder\etc\system\local\authentication.conf”

Does the action script look correct?

I’m not sure the intent of the line that is failing…

wait __Download\deploymentclient.conf

That would try to execute the conf file. I’d remove that line and try the rest of the script as-is.

1 Like

Thanks Jason!

This is what I have and it works

prefetch 88f8ec066544b7c6b5ff175d85cf49a32d317dea sha1:88f8ec066544b7c6b5ff175d85cf49a32d317dea size:141 http://BDOWSPBGFX:52311/Uploads/88f8ec066544b7c6b5ff175d85cf49a32d317dea/deploymentclient.conf.tmp sha256:244cd924e7b0df2d8fdfc3475504040bda36b417146e60af204498ff4909327c
extract 88f8ec066544b7c6b5ff175d85cf49a32d317dea
//
action uses wow64 redirection false
//
delete “C:\Program Files\SplunkUniversalForwarder\etc\system\local\deploymentclient.conf”
//
copy “__Download\deploymentclient.conf” “C:\Program Files\SplunkUniversalForwarder\etc\system\local\deploymentclient.conf”

1 Like