Relevance that looks for files found in wwwrootbes\Uploads folder

I am trying to create a task that will copy a json file to a directory on a Linux server. The relevance to check a folder, within the “wwwrootbes/Uploads” folder, for a filename that matches the computer name. If a match is found, I want the json file copied to a directory on the Linux endpoint. The process of copying the file to the directory isn’t as much of an issue as checking the “http://:52311/Uploads/special” folder for a matching filename.

Any Ideas?

“By the book” method would be to use the REST API. You’d have a task run on the server itself to scan the Uploads directory, create a manifest file for the url, size, sha1, and sha256 of each found file, attach that resulting manifest file to a custom site, and the clients would parse the manifest to determine the downloads to grab.

If the files don’t change frequently, you could also do that manually.

Ignoring the book, you could use curl from a client task to grab the file directly. However that would require direct access to the root server, and would not take advantage of the relay deployment bandwidth management or file caching capabilities.

Do you have any examples on using the “by the book” method?

Hello RobRuss,

You might try the following relevance to check a folder “test1”, within the “wwwrootbes/Uploads” folder, for a filename that matches the computer name:
exists file (computer name as lowercase) of folder "test1" of folder "Uploads" of folder (value of settings "_BESRelay_HTTPServer_ServerRootPath" of client)

And if you want to make sure you’re dealing with a server, you might also check something like that:
exists main gather service

Regards,
Vitaliy

1 Like

I also ran into an issue in fixlet creation, with action using the computer name as a parameter. How do I substitute the filename for the parameter using the “computer name”?
for example, if the computer name is “server5”, I want it to download:

http://:52311/Uploads/special/server5”

I tried the following
Download http://cmgdtcpasbfsvr1.cmg.int:52311/Uploads/facter/{parameter “computer name”}

Rob, Great question! Early in my BigFix career I had to do a similar thing and discovered that Download command does not allow for {relevance substitution} because it breaks all of the relay caching stuff upstream.

You can use relevance substitution in a Download Now command, but it will cause a delay while your action runs, as the file will be downloaded while the action is running, instead of before the action starts.

https://developer.bigfix.com/action-script/reference/download/download-now.html

Try:
download now as "myfile.txt" https://brollybes7:52311/Uploads/{computer name & ".txt"}

or with your filenames:
Download now as "MyFile.txt" http://cmgdtcpasbfsvr1.cmg.int:52311/Uploads/facter/{computer name}

(and don’t forget to convert the “smart quotes” into normal quotes…)

A less “old school method” would be to use the pre-fetch blocks as described here:
https://developer.bigfix.com/action-script/reference/download/add-prefetch-item.html