Link to home
Start Free TrialLog in
Avatar of chrabark
chrabark

asked on

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?
Avatar of ahoffmann
ahoffmann
Flag of Germany image

$env(CES_HOME)
Avatar of chrabark
chrabark

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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...
what does folloing return:

  array names env
I can't figure out how/where to execute that line... sorry, not very familiar with WISH/TCL
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)
% 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...
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
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
}

proc oilspill {} {
global env
exec $env(CES_HOME)/bin/oilspill.form
}
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
as I already said in http:#14412867 ;-)