WISH and environment variables

I have a wish script being executed with the following code segment...

#! /bin/wish -f
wm title . "Forms"
frame .rc -borderwidth 2
pack .rc
button .rc.b -text "Oil Spill" -command {oilspill}
button .rc.c -text "Quit" -command {exit}
pack .rc.b .rc.c -side left
.rc configure -background tan
.rc.b configure -background tan -foreground black
.rc.c configure -background red -foreground white
proc oilspill {} {
exec $CES_HOME/bin/oilspill.form
}

Problem is, the variable is not being translated within the script... I can execute 'exec $CES_HOME/bin/oilspill.form' from the commandline just fine, and I can hardcode the path within the script, but I need to use the environment variable to call it.

Any suggestions?
chrabarkAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ahoffmannCommented:
$env(CES_HOME)
chrabarkAuthor Commented:
Still not working... I am getting this
"   Error: can't read "forms_home": no such variable   "

#!/bin/wish -f
set forms_home $env(CES_HOME)
...
proc oilspill {} {
exec $forms_home/bin/oilspill.form

----Chris
ahoffmannCommented:
is this variable CES_HOME exportetd to your tcl script?
what does following return
  puts  $env(CES_HOME)

Also:

proc oilspill {} {
  global forms_home
  exec $forms_home/bin/oilspill.form

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

chrabarkAuthor Commented:
Sorry took a while to get back, been bogged down with production issues elsewhere...

but when invoking puts  $env(CES_HOME)...

can't read "env": no such variable
can't read "env": no such variable
    while executing
"puts $env{CES_HOME}"

when I do a 'set' from the command prompt, the CES_HOME variable exists with the proper path...
ahoffmannCommented:
what does folloing return:

  array names env
chrabarkAuthor Commented:
I can't figure out how/where to execute that line... sorry, not very familiar with WISH/TCL
ahoffmannCommented:
ok, please start in a shell:
  tclsh
or start:
  wish

then key in these commands:
  array names env
  puts  $env(CES_HOME)
  puts  $env(HOME)
chrabarkAuthor Commented:
% array names env
HISTFILE HOME CES_DM_USER COLUMNS CES_DRAWINGS HISTSIZE LOGNAME DIAG_LOGDIR SHLIB_PATH CVS_ROOT SHELL VFONT_DIR CES_SQL_FILES ISISREMOTE ISISPORT MB_META_HOSTS TZ ISISHOST LAPACK_ROOT XRTHOME USER SYMBOLOGY_SET RDL_DIR PREFERRED_ALIAS DATEMSK MANPATH RDBMS_TYPE ISIS_PARAMETERS CMM_CELL ORACLE_SID XAPPLRESDIR XBMLANGPATH CES_SITE UIDPATH TMPDIR __ARIES_PA_AOUT_MAXSSIZ UNIX95 VIEW_GEOMETRIES_NO_EMAN LINES SIL_VER LIBPATH ORACLE_TERM PATH VBUILD CES_SYSDATE OPERATIONS_MODELS IFACE_SRC _ EDITOR PTHREAD_COMPAT_MODE LD_LIBRARY_PATH CES_LOG_DIR RDBMS_HOSTS_DIRECT PWD RDBMS_HOST VISIBLE_FOCUS SETUP_MODE ORACLE_HOME DISPLAY LOG_DIRECTORY __ARIES_PA_STACK_SIZE_max CES_DM_INSTANCE CES_PACKAGE_FILES CVSROOT ERASE ENV CES_BASE_SYMBOLOGY __ARIES_PA_STACK_SIZE_cur CES_PDM_PLB_FILES CES_HOME OPERATIONS_RDBMS ORACLE_HOST PS1 EASI_ROOT WINDOWID VIEW_GEOMETRIES RDBMS_USER DBPKG CES_SERVER RDBMS_PASSWD CES_DM_PASSWD CMMSREMOTE CES_PDM_SQL_FILES CMMSPORT TERM CVS_RSH PKG CES_ADMIN CES_PDM_BIN_FILES CES_INDEX_TABLESPACE CES_DATA_FILES FCEDIT

% puts $env(CES_HOME)
/app/omapplte/u01/oms

% puts $env(HOME)
/app/omapplte/u01/home/omstesvc

so, what seems to be wrong then?  i'm lost...
ahoffmannCommented:
conclusion: all my suggestions work
if they do not work in your script and/or you get your posted error messages, then the corespondig variable CES_HOME is not set when the script is run
chrabarkAuthor Commented:
K, tried launching Wish another way... and adding the variable as the button name (which works !), but the exec still does not?  Does this help at all ?

#!/bin/ksh
# the next line restarts using wish \
exec wish "$0" "$@"

wm title . "Forms"

frame .rc -borderwidth 2
pack .rc

button .rc.b -text $env(CES_HOME) -command {oilspill}

pack .rc.b -side left

.rc configure -background tan
.rc.b configure -background tan -foreground black

proc oilspill {} {
exec $env(CES_HOME)/bin/oilspill.form
}

ahoffmannCommented:
proc oilspill {} {
global env
exec $env(CES_HOME)/bin/oilspill.form
}
chrabarkAuthor Commented:
See, I knew if I increased the point value, it would help get to the root of the problem !

Thanks for all your patience and effort, the 'global' statement was the fix that I needed.

--cb
ahoffmannCommented:
as I already said in http:#14412867 ;-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.