Copy file and run bash script

Hi all,

I have an action which run as a “sh” script.

Some thing simple like:

*******

tar -xvf myfile.tar.gz

./installme.sh

******

I want the file “myfile.tar.gz” to be hosted on the Bigfix server it self so every server that is connected to Bigfix will be able to d/l it fromthe server.

How can I first d/l the file to the client server and then run my bash script?

(Using Bigfix 11.0.4).

Editing:

I saw on the web I can write: download http://127.0.0.1:52311/Uploads/samplefile.txt

but this seems to work when the action script type is set to: “Bigfix action script” and I am choosing “sh” as action script type to run my bash commands.

Thanks,

Roy

My approach would be to change the action to the ActionScript type then either download the tar file and a version of the script you want to run then call the downloaded copy of the script, or download the tar then use appendfileor createfile to dynamically create the script on the fly then execute it.

Take a look at the client or relay install fixlets in the BES Support site for examples of using ActionScript to download and create/execute a script (these use appendfileto create a script on the fly)

Hi,

I will try to look for a relevent fixlet in the list.

I have a filling it doesn’t really d/l my file even due I don’t see any error in the log.

I have a file “file1.txt” in:

D:\Program Files (x86)\BigFix Enterprise\BES Server\wwwrootbes\Uploads

and a simple tesk like this:

prefetch file1.txt sha1:a843c7c723efa18c80159a7c61ad60024e8b2ec4 size:593296445 http://127.0.0.1:52311/Uploads/file1.txt sha256:2430c7eddf2c65f19b5c85cffec61cd8088f6aa29cb29f751782cb906bb588c9


wait /bin/bash -c "cp /var/opt/BESClient/__BESData/__Global/__Download/file1.txt /tmp/"

Thats as simple as it goes. Yet, the file seems to not be in /tmp at the end and I don’t see it in the __Download dir also. unless it sould be delete from there imediatlly….

In the log I see:

Command succeeded (Prefetch download manager collected file) prefetch file1.txt sha1:a843c7c723efa18c80159a7c61ad60024e8b2ec4 size:593296445 http://127.0.0.1:52311/Uploads/file1.txt sha256:2430c7eddf2c65f19b5c85cffec61cd8088f6aa29cb29f751782cb906bb588c9 (action:45213)
Command started - wait /bin/bash -c "cp /var/opt/BESClient/__BESData/__Global/__Download/file1.txt /tmp/" (action:45213)
Command succeeded (Exit Code=1) wait /bin/bash -c "cp /var/opt/BESClient/__BESData/__Global/__Download/file1.txt /tmp/" (action:45213)
At 12:37:54 +0300 -
ActionLogMessage: (action:45213) ending action

So every thing looks good but I don’t see the file.

You can copy the file with native actionscript methods.

prefetch file1.txt sha1:a843c7c723efa18c80159a7c61ad60024e8b2ec4 size:593296445 http://127.0.0.1:52311/Uploads/file1.txt sha256:2430c7eddf2c65f19b5c85cffec61cd8088f6aa29cb29f751782cb906bb588c9
delete /tmp/file1.txt
copy __Download/file1.txt /tmp/file1.txt

This is easier than pathing to the “expected” folder via an OS level method as the folder may vary depending on fixlet site or operator (NMO vs MO)

Also, though I’m sure you are aware, downloads via the loopback address will only work on the root server so downloads will fail on any other endpoints :wink:

1 Like

Hi SLB,

Just managed to d/l the file and copy it using the action scripts commands. After that I used the /bin/bash -c “command” to run the other command and it seems to work.

Thanks a lot for your replay. I appreciate it very much.

Roy.

2 Likes