"move" and "copy" __Download/filename /Destination fail on Linux client

the following command works on my test Linux server:
move “/var/opt/BESClient/__BESData/__Global/__Download/test.sh” "/tmp/test.mv

But the followinf commands do not work on the same server:
move __Download/test.sh /tmp/test.mv
copy __Download/test.sh /tmp/test.mv

move “__Download/test.sh” "/tmp/test.mv"
copy “__Download/test.sh” “/tmp/test.mv”

Where am I going wrong? I have searched the forum with no luck on finding any leads.

Cheers,
Emil

The copy command fails if the destination already exists or if the copy fails for any other reason such as when the destination file is busy.
The move command fails if the destination already exists, if the source file doesn’t exist, or if the move fails for any other reason.

https://developer.bigfix.com/action-script/reference/file/copy.html
https://developer.bigfix.com/action-script/reference/file/move.html

It’s safe (and common practice) to run delete before the move/copy as it won’t fail even if the file doesn’t exist.

https://developer.bigfix.com/action-script/reference/file/delete.html

I am aware of the conditions stated above and use “delete” as common practice in my scripts.

In my test case:

  • The source file exists
  • the destination folder exists
  • the destination file DOES NOT exist
  • The move command works when I provide the explicit source file path but fails when I use the BES variabale “__Download” as the befining of the source path
  • No valuable error data is provided when the command fails.

Thoughts?


Emil

“__Download” is not a BES variable, it’s just a pathname that should be relative to the working directory. The current working directory should be /var/opt/BESClient/__BESData/<SiteName>.

If test.sh is a file you downloaded with the ‘prefetch’ or ‘download’ commands, it’ll be in the __Download folder. If it’s a file you created with ‘createfile’ or ‘appendfile’, it won’t be in the download folder, it’ll just be in the current directory.

Try using "./test.sh" or "./__Download/test.sh", and see whether those work.

Oh! Just noticed your original is pulling test.sh from the global download folder, not the download folder for this specific action!
Don’t do that, you may not be pulling the file you expect, it some other action downloaded test sh!