Set user variable with PARAMETER

I need help with syntax. I am successfully using parameters else where in my script. But for this portion, I cannot figure out the proper syntax for this particular substitution. It has to be the combination of curly brackets and double quotes.

Thanks in advance for your help.

This is a sample of one of my many attempts:

parameter "OLD_JAVA_VERSION" = "jdk1.8.0_131"
parameter "NEW_JAVA_VERSION" = "jdk1.8.0_141"
parameter "OLD_JAVA_TAR" = "jdk-8u131"
parameter "OLD_JAVA_TAR_FULL" = "jdk-8u131-linux-x64.tar.gz"
parameter "NEW_JAVA_TAR" = "jdk-8u141"

if {exists folder "/usr/lib/jvm/{parameter "OLD_JAVA_VERSION"}"}
wait rm -rf /usr/lib/jvm/{parameter "OLD_JAVA_VERSION"}}
endif
if {exists file "/usr/lib/jvm/{parameter "OLD_JAVA_TAR_FULL"}"} 
delete "/usr/lib/jvm/{parameter "OLD_JAVA_TAR_FULL"}"
endif

This paragraph is what (in reality) I want the script to look like and execute.

if {exists folder "/usr/lib/jvm/jdk1.8.0_131"}
wait rm -rf /usr/lib/jvm/jdk1.8.0_131}
endif
if {exists file "/usr/lib/jvm/jdk-8u131-linux-x64.tar.gz"} 
delete "/usr/lib/jvm/jdk-8u131-linux-x64.tar.gz"
endif

Yea this is the problem… you are trying to do relevance substitution inside relevance substitution…

You should do the following

if {exists folder "/usr/lib/jvm" whose ( exists folder ( parameter "OLD_JAVA_VERSION" ) of it )}

However not sure why you’re doing this at all

I’d just do the following

folder delete "/usr/lib/jvm/{parameter "OLD_JAVA_VERSION"}"
delete "/usr/lib/jvm/{parameter "OLD_JAVA_TAR_FULL"}"

as both will handle the target not existing

1 Like

I made some minor edits and corrections.

Much easier to do that. Also don’t need to check existence before deletion in that case.

I’ll give this a try. Thank you for the help.

Alan,

Your suggestion works great! Thanks for taking the time to respond.

Ken