LabTech Support Forums

share script variable between several machines

This forum is for discussion of script related issues.

Moderator: jware.connectwise

share script variable between several machines

Postby brink.totalbusinessware » Wed Dec 28, 2016 10:55 pm

Hi,

I am looking for some "best practice" or high level advice. I am very new to LT and see several potential solutions to this problem.

I need to run software upgrades on several machines, but only after machine 1 has successfully run the upgrade. I am using "set variable" constant and "variable check" but its not working. My assumption was that since the set variable constant function runs on the server it would be available to the other machines running the same script at the same time. That does not appear to be the case. Is there a way to do this with variables?

Instead of variables, I could poll a "flag.txt" file as suggested here: viewtopic.php?f=100&t=17388&p=26759&hilit=variable+check#/ -not very elegant, but it would work.

Or maybe since the software needs to have same version across the location, I should create an EDF at the location level and use EDF SET / EDF GET.

Anyone care to weigh in or suggest better ideas?

Thanks in advance,

Bob
brink.totalbusinessware
Newbie
Newbie
 
Posts: 5
Joined: Thu Dec 15, 2016 11:06 pm

Re: share script variable between several machines

Postby teamits » Thu Dec 29, 2016 12:54 pm

Variable Set is per script run.

Script State is saved for that computer, across script runs. (to the point of, remember to reset the variable when the script completes successfully)

If you need a value that can differ for each location using a custom field is probably the best bet.
Steve
teamits
Hero Member
Hero Member
 
Posts: 1577
Joined: Wed Dec 31, 1969 8:00 pm

Re: share script variable between several machines

Postby brink.totalbusinessware » Thu Dec 29, 2016 1:19 pm

Hi,

>Variable Set is per script run.

To be perfectly clear, if I run 1 script simultaneously on 5 computers, you consider that 5 "script runs"?

thanks again,

Bob
brink.totalbusinessware
Newbie
Newbie
 
Posts: 5
Joined: Thu Dec 15, 2016 11:06 pm

Re: share script variable between several machines

Postby teamits » Thu Dec 29, 2016 1:24 pm

if I run 1 script simultaneously on 5 computers, you consider that 5 "script runs"?

Yes they are separate. Some PCs may be off, etc. It queues them individually on each computer.
Steve
teamits
Hero Member
Hero Member
 
Posts: 1577
Joined: Wed Dec 31, 1969 8:00 pm

Re: share script variable between several machines

Postby ian.integra-xp » Tue Jan 03, 2017 10:15 am

As teamits mentioned, the script runs on each machine. So, to do it in a more labtech way you could just run the script on each machine which need to have package X, but check to see if machine N has the software installed before continuing on to install.

I've attached a small script which, if you run it on a box, it will check to see if dropbox is installed on node 1 (node Id 1 normally being your own Labtech server). The script is called ixp-test. You could easily add some logic to this to do the following:

If i am node 1
install dropbox
exit script
other wise
change context to node 1
if dropbox is installed then exit script
other wise
change context back to original node
install dropbox
end
end

To really do this the labtech way, you would then create a group in LT and schedule the script to run each monday, this way you would run the script on the whole group but only those members who do not have the package installed would get it installed.

To make this more labtech-like, the membership of the group would be comprised of machines selected via a search query. Thus you could create a search of PC's which are in a particular client and who do not have package X installed. The group would then only contain the nodes at that client which do not have the package, and the script would be run on these.
Attachments
ixp-test.7z
(1.3 KiB) Downloaded 63 times
-- Ian Murphy
ian.integra-xp
Hero Member
Hero Member
 
Posts: 570
Joined: Tue Nov 15, 2011 12:29 pm


Return to Scripts

Who is online

Users browsing this forum: No registered users and 3 guests

cron