Copy syntax failing

Hi,

I’m trying to simply copy a file over to a local folder from “__Download” without any success. This makes zero sense because last year’s version of the fixlet worked fine and I copy/pasted the code.

prefetch blahblahblah sha1:blahblahblah size:2041 http://bigfixserver.company.com:12345/Uploads/blahblahblah/file.txt.tmp sha256:blahblahblahblah
extract blahblahblah
copy __Download\file.txt "C:\Temp\file.txt"
run “C:\Program Files\Some_Program\program.exe” -s “datafile:c:\Temp\file.txt”

The copy part is whats failing. “C:\Temp” does exist. What gives?

Thanks

Copy fails if the destination file exists - it will not overwrite an existing file

prefetch blahblahblah sha1:blahblahblah size:2041 http://bigfixserver.company.com:12345/Uploads/blahblahblah/file.txt.tmp sha256:blahblahblahblah

extract blahblahblah

delete "c:\temp\file.txt"
copy __Download\file.txt "C:\Temp\file.txt"

run “C:\Program Files\Some_Program\program.exe” -s “datafile:c:\Temp\file.txt”

How come it worked before? I literally just changed the name of the file and nothing else from the previous version of this fixlet.

Possibly this isn’t the solution if the file name has changed - I just noticed your comment that a previous version worked and you did copy & paste and assumed the destination file existed

Tried the delete string. It did not keep the fixlet’s copy syntax from failing. This is unreal…

The only other way a copy can fail is if the source file doesn’t exist. I assume your source file, __Download\file.txt, is produced by extracting the download. Are you sure that file.txt.tmp is a proper BFArchive that contains the file.txt? The client log should show you exactly why it’s failing on the copy command.

If I know I’m not going to work out of __Download, I’ll often just extract the files directly to the destination folder in the prefetch/extract statement. So that would look like:

prefetch blahblahblah sha1:blahblahblah size:2041 http://bigfixserver.company.com:12345/Uploads/blahblahblah/file.txt.tmp sha256:blahblahblahblah
extract blahblahblah "C:\Temp"

That’s also useful because it’ll be able to tell you whether you’re working with the file you think you are. If “C:\Temp\file.txt” exists, then there’s no reason “__Download\file.txt” wouldn’t either. I sometimes do this during fixlet testing just as a sanity check that the files post download/extraction are in the same folder structure that I expect.

The only disadvantage of this method is that the files you extract will stay on the system’s hard drive, rather than being deleted automatically out of __Download at the end of the action.

1 Like