Jump to content
Ketarin forum

Getting an Environment Variable into Ketarin


jeff9315
 Share

Recommended Posts

I don't believe there is any way to get an Environment Variable into Ketarin. I would really like to be able to get access to the Computer Name that I'm on. I'd primarily want it so I can customize the download directory so that it would be something like

H:\Ketarin\Downloads\Computer_Name\Category_Name

Anybody have any workarounds you can suggest?

 

Ideally, a future version of Ketarin would either allow access to all Environment Variables or there would be a way to create a Ketarin Global Variable through the commandline such as

h:\ketarin /PARM="COMPUTERNAME:"Starfish"

so that the Ketarin Global variable {COMPUTERNAME} would be "Starfish"

Link to comment
Share on other sites

It's not possible to set a value directly, nor include environment variables via programmatic access within Ketarin. However, if you're wanting to set the save-to path, I can see two different methods. One is to use the "before updating an application" script to parse the param and set the value directly. The other would be to run a command directly against the database immediately before loading Ketarin. Something like this should work:

sqlite3 jobs.db "update variables set CachedContent = '%computername%' where VariableName = 'pcname';"

This requires sqlite3.exe in your path, and you'd need to create the variable 'pcname' and use that value within your save-to values before you run the script, of course. This is the way I'd go simply because it's so much more universal.

Link to comment
Share on other sites

  • 3 years later...

Any chance this might have been implemented in a later Ketarin build?  If it hasn't, I'd like to submit it as a feature request.

 

I want to do something along the same lines as jeff9315, but in my case I would like to manipulate an application level variable that is dynamically assigned using "before updating an application" to be used both in the download path and in the "after updating an application" script.  I'm currently doing this with a static variable, but could be automated if done dynamically.

 

PS: I'd happily use shawn's suggestion; however if I understood it correctly updating the variable using sqlite is done before launching Ketarin and I'm looking for something that changes after Ketarin has already been opened.

Link to comment
Share on other sites

Any chance this might have been implemented in a later Ketarin build?  If it hasn't, I'd like to submit it as a feature request.

 

I want to do something along the same lines as jeff9315, but in my case I would like to manipulate an application level variable that is dynamically assigned using "before updating an application" to be used both in the download path and in the "after updating an application" script.  I'm currently doing this with a static variable, but could be automated if done dynamically.

 

PS: I'd happily use shawn's suggestion; however if I understood it correctly updating the variable using sqlite is done before launching Ketarin and I'm looking for something that changes after Ketarin has already been opened.

 

Through Ketarins recently added ability to run Powershell scripts, it is possible to modify global and application variables during the pre/post update commands:

# Local Set
$app.variables.appv.TextualContent = "My new content"
#
# Local Get
$app.variables.appv.TextualContent
#
# Note: "appv" is created manually before local set/get. At creation, its type is set to "Textual content".

# Global Set
$globalvars.globv.CachedContent = "My new content"
#
# Global Get
$globalvars.globv.CachedContent
#
# Note: "globv" is created manually before global set/get.

Regarding their use :

In post-download scripts : Changes made in the pre-download script will be available.

In download paths : Changes made - in the current update cycle - in the pre-download script, will not be available. That is, the stored values from the previous download cycle will be used. 

 

I would avoid modifying the database directly; multiple actors, unaware of each other, modifying common state, at indeterminate times -- is a recipe for headaches.

Link to comment
Share on other sites

  • 2 weeks later...

First of all, please don't touch the database, thanks! ;)

 

Next, I think I can easily implement a solution for such cases. I will provide a function "runpowershell" (and "ps" as shortcut) with the next version, that simply runs a PowerShell script.

 

So in other words: Create a new variable with the textual content (or global var) "$env:computername".

Then use the variable like this: {test:ps}

 

Sounds good?

Link to comment
Share on other sites

First of all, please don't touch the database, thanks! ;)

 

Next, I think I can easily implement a solution for such cases. I will provide a function "runpowershell" (and "ps" as shortcut) with the next version, that simply runs a PowerShell script.

 

So in other words: Create a new variable with the textual content (or global var) "$env:computername".

Then use the variable like this: {test:ps}

This would certainly be useful, thx.

Some questions about the solution :

a. I presume the script would run before the pre/post-update scripts?

b. If a multi-line script, is the value of the url-variable the last printed Powershell variable?

c. Does the url-variable-script have access to its state, from the previous run; does it have access to other variables/global vars?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.