Copy local file to remote unix server

(imported topic written by srage91)

Hi all,

Am very new to bigfix. Currently trying to create a custom fixlet to perform some task.

How do I copy a file from a window machine to a unix server.

  1. The file can be a compressed file aka zip file, or any regular text file.

  2. The file will be located in a generic folder eg. c:\temp\temp1 or c:\temp\temp2

I am aiming to customise the fixlet to read from the folder, and ftp or copy the file over to my unix server.

For such a scenario, how should I code my action/relevance language?

Best regards

Eugene

(imported comment written by BenKus)

Hi Eugene,

You can use actionscript to do the copy, but can you set up a location on your unix server to accept a file copy from an unauthenticated account?

Ben

(imported comment written by srage91)

Ben Kus

Hi Eugene,

You can use actionscript to do the copy, but can you set up a location on your unix server to accept a file copy from an unauthenticated account?

Ben

Hi Ben,

May I know the syntax of the action script to do this?

Basically my agent is running as root user, so there shouldn’t be any authorization issue I believe.

Any sample of how such an action script should be, in order to perform such an action?

And what should be the detailed actions be like? What I actually did is as follow:

  1. Calculate the SHA1

  2. Rename my file with the SHA1 value

  3. Place the file in the bigfix folder

  4. Execute my task.

Eugene

(imported comment written by BenKus)

Ah… so you arent trying to copy a file from one Windows computer to a Unix computer, you want to use an action to distribute a file to your Unix computer?

You would create an action that looks like this:

prefetch filename sha1:3c13a810c49ecef0291ea14877d37d0e81e9d00c size:249856 http://someserver.com/somefolder/somefile

move __Download/filename /somedestination/filename

Then just replace all the values with urls, filenames, sha1s, etc.

Ben

(imported comment written by srage91)

Yah, It’s some sort of distributing mechanism.

Regarding the prefetch,

prefetch filename sha1:3c13a810c49ecef0291ea14877d37d0e81e9d00c size:249856 http://someserver.com/somefolder/somefile

How do I interpret the above prefetch statement? Why is it a http connection?

Sorry for asking such simple question. Totally new to bigfix env, and trying to pick up currently.

Eugene

(imported comment written by srage91)

Let’s say if I place the file directly into the SHA1 folder after renaming the file to the SHA1 value of the file, can I perform the distribution directly?

Or do I need to follow through the flow, of downloading it, then let bigfix do the work?

Current situation is that the file I intended to distribute is on the bigfix machine itself:

  1. File located at c:\temp

  2. Bigfix installed at c:\program files\bigfix

What should I do from here?

Eugene

(imported comment written by BenKus)

Hey Eugene,

Here is what I think you are asking:

You want to take a file that exists on the BigFix Server and deploy it to Unix BigFix Agents. Is that correct?

The method you used was basically to pre-cache the file, which should work, but you might get better results if you put the file in the Uploads folder so you can be sure it isn’t going to get removed from the cache… You would then do something like this:

prefetch filename sha1:3c13a810c49ecef0291ea14877d37d0e81e9d00c size:249856 http://127.0.0.1:52311/Uploads/somefile

This command instructs the agent to ask the server for this file. The url is the location the server will go to get the file. The reason we use HTTP is because that is how files are distributed in BigFix.

Does that help and make sense?

Ben

(imported comment written by srage91)

Ben Kus

Hey Eugene,

Here is what I think you are asking:
You want to take a file that exists on the BigFix Server and deploy it to Unix BigFix Agents. Is that correct?

The method you used was basically to pre-cache the file, which should work, but you might get better results if you put the file in the Uploads folder so you can be sure it isn’t going to get removed from the cache… You would then do something like this:
prefetch filename sha1:3c13a810c49ecef0291ea14877d37d0e81e9d00c size:249856 http://127.0.0.1:52311/Uploads/somefile

This command instructs the agent to ask the server for this file. The url is the location the server will go to get the file. The reason we use HTTP is because that is how files are distributed in BigFix.

Does that help and make sense?
Ben

Hi Ben,

This is a great explaination which I am indeed looking for.

Abit of things that I would like to further clarify.

  1. http://127.0.0.1:52311/Uploads/somefile : what path does it refer to on the local host? c:\uploads or c:[bigfix installed directory]\uploads

  2. Based on the prefetch url, do we need to ensure that the port 52311 is opened? Cause due to the environment I am in, we have blocked out all unnecessary ports.

  3. Do we need to rename the file just like how we renamed it when we “precached” it manually or just leave it as it is? or the bigfix agent will do it automatically?

  4. I seen __download in some fixlets, where does this __download point to? Only assumption that I can make out of it is that, __Download is the cache folder, but just to confirm, what is the path that it’s actually pointing to? Eg.

move __Download/filename /somedestination/filename

. I assume __Download/

filename

is referring to the local window machine, and /somedestination/

filename

is referring to the remote machine.

Thanks alot again.

Eugene

(imported comment written by gjeremia91)

  1. “C:\Program Files\BigFix Enterprise\BES Server\wwwrootbes\Uploads” - it will not exist by default but will be created when you use the Windows SOftware Distribution Wizard (just an example)

  2. if port 52311 is not open then BES will not work, unless you have alredy told it to use another port. This is the same port that your clients use to communicate with the BES Server and BES Relays, that said, most firewalls will not affect you loop back interface anyway !

  3. Using the URL provided, you do not need to rename your file. When that file is requested, BES Server will cache it from the url (i.e. it will cache it from itself) which is just like precaching. Then once it has cached it, it will provide it to your clients. Your clients will not directly use the url provided, but instead ask the BES Infrastructure to get the file.

  4. because of the explaination of 3) : when the file is obtained by the client it is actually downloaded from the BES Server/Relays into __Download. So to move the file, it is located in a directory “__Download”. This is a path RELATIVE to where the action script is being executed, which is the site direcotry of your BES Client install, i.e.

c:\program files\bigfix enterprise\BES Client__BESData<your custom site or actionsite>__Download

So you could write a very log line:

copy 
"c:\program files\bigfix enterprise\BES Client\__BESData\<your custom site or actionsite>\__Download\somefile.ext" 
"/some/location/"

or you could use the relative path as shown in Ben’s response.

hope that helps

  • Garreth

(imported comment written by srage91)

gjeremia

  1. “C:\Program Files\BigFix Enterprise\BES Server\wwwrootbes\Uploads” - it will not exist by default but will be created when you use the Windows SOftware Distribution Wizard (just an example)

  2. if port 52311 is not open then BES will not work, unless you have alredy told it to use another port. This is the same port that your clients use to communicate with the BES Server and BES Relays, that said, most firewalls will not affect you loop back interface anyway !

  3. Using the URL provided, you do not need to rename your file. When that file is requested, BES Server will cache it from the url (i.e. it will cache it from itself) which is just like precaching. Then once it has cached it, it will provide it to your clients. Your clients will not directly use the url provided, but instead ask the BES Infrastructure to get the file.

  4. because of the explaination of 3) : when the file is obtained by the client it is actually downloaded from the BES Server/Relays into __Download. So to move the file, it is located in a directory “__Download”. This is a path RELATIVE to where the action script is being executed, which is the site direcotry of your BES Client install, i.e.

c:\program files\bigfix enterprise\BES Client__BESData<your custom site or actionsite>__Download

So you could write a very log line:

copy
"c:\program files\bigfix enterprise\BES Client__BESData<your custom site or actionsite>__Download\somefile.ext"
"/some/location/"

or you could use the relative path as shown in Ben’s response.

hope that helps

Garreth

Hi,

Thanks alot for the information. Helps a great deal in understanding more on the action scripts, and on what they’re doing.

Managed to get it working, just a simple transfer of file from a window machine to a remote solarix unix machine, and it’s a good enough starter for me currently.

Eugene