can't read env(DISPLAY) from regexp with $env(DISPLAY) 
Author Message
 can't read env(DISPLAY) from regexp with $env(DISPLAY)

I have been working on some expect stuff so that I can automate remote x
connections and have run into a snag..... the code is below as well as
the response from the interpreter...... and when I run the code at the
expect prompt (at least the regexp line) it works perfectly..... any
idea what gives? no matter what I do expect tells me theres no
such variable as env(DISPLAY) from inside the script....... It must be
that I haven't declared something somewhere or I have failed to put the
right quotes/brackets/etc but it must be so obvious that I just can't
see it....

***************************************************
here's the code..... simple proc to pull the DISPLAY.. I no there's more
elegant ways to do the regexp but here was a chance to try one and I
mucked it up at that
***************************************************
proc getlocalxdisplay { } {
# get the current DISPLAY and parse it
 regexp (.*):(.*) $env(DISPLAY) ignore localhost displaynum
 if { [string compare $localhost ""] == 1} {
# that is to say, if the local DISPLAY returns :0
# localhost will come up null
# which means that the user is on a 250
#
# domainname is essentially the proc by the same name from THE BOOK
#
        set nodename [ exec hostname ]
        set xdisplay "$nodename.[domainname]:$displaynum"
 } else {
        set xdisplay $env(DISPLAY)
 }
 return $xdisplay

Quote:
}

*********************************************************
and here's what it spits out.....
*********************************************************
can't read "env(DISPLAY)": no such variable
    while executing
"regexp (.*):(.*) $env(DISPLAY)..."
    (procedure "getlocalxdisplay" line 3)
    invoked from within
"getlocalxdisplay"
*********************************************************
and here's the same thing from the command line.....
**********************************************************
expect1.1> regexp (.*):(.*) $env(DISPLAY) ignore localhost displaynum
1
expect1.2> set localhost
expect1.3> set displaynum
0
expect1.4>


Tue, 11 Apr 2000 03:00:00 GMT  
 can't read env(DISPLAY) from regexp with $env(DISPLAY)


Quote:
>proc getlocalxdisplay { } {
> regexp (.*):(.*) $env(DISPLAY) ignore localhost displaynum

scooooooope....  gloooobal....

--
    Jeffrey Hobbs               "I'm really just a Tcl-bot"
    jeff.hobbs at acm.org | Jeffrey.Hobbs at oen.siemens.de



Sat, 15 Apr 2000 03:00:00 GMT  
 can't read env(DISPLAY) from regexp with $env(DISPLAY)

You need to have env in global scope.  It might also help to
put your regular expression inside {}.  

        proc getlocalxdisplay { } {
             global env
             regexp {(.*):(.*)} $env(DISPLAY) ignore localhost displaynum
             ...

Hope this helps.

Will

Quote:
>proc getlocalxdisplay { } {
># get the current DISPLAY and parse it
> regexp (.*):(.*) $env(DISPLAY) ignore localhost displaynum
> if { [string compare $localhost ""] == 1} {
># that is to say, if the local DISPLAY returns :0
># localhost will come up null
># which means that the user is on a 250
>#
># domainname is essentially the proc by the same name from THE BOOK
>#
>        set nodename [ exec hostname ]
>        set xdisplay "$nodename.[domainname]:$displaynum"
> } else {
>        set xdisplay $env(DISPLAY)
> }
> return $xdisplay
>}

--
# Copyright 1997 Will Morse.  Internet repost/archive freely permitted.
# Hardcopy newspaper, magazine, etc. quoting requires permission.
#
#      Gravity,                    #    Will Morse
#      not just a good idea,       #    Houston, Texas

#
#   These are my views and do not necessarly reflect anyone else/
 =========================================================================
      By US Code Title 47, Sec.227(a)(2)(B), a computer/modem/printer
      meets the definition of a telephone fax machine. By Sec.227(b)
      (1)(C), it is unlawful to send any unsolicited adverti{*filter*}t to
      such equipment, punishable by action to recover actual monetary
      loss, or $500, whichever is greater, for EACH violation.
 =========================================================================


Fri, 21 Apr 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. unset env, array set env ...

2. expect can't read env(TCL_LIBRARY)

3. parsing ENV['PATH']

4. ENV['HOME'] on win32

5. unshifting a directory onto ENV['PATH']

6. Empty strings and 'env' array weirdness

7. Dos Env Read & write

8. read compress file in Unix env.

9. Testing and reading env variables on Windows

10. Reading REMOTE_USER from env do not work

11. set dos env's in clipper app??????

12. set dos env's in clipper app??????

 

 
Powered by phpBB® Forum Software