Home > Archive > Tcl > April 2007 > Packages and Expect
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Packages and Expect
|
|
| Tom Conner 2007-04-30, 4:17 am |
| I installed ActiveTcl8.4.14.0 and, as usual, it has everything and the
install was painless. However, I have one question regarding packages and
other libs. Everything, except for Expect, I just "package require <package
name>". Expect I use
load <path to expect .so>/libexpect.so
Is there any way to "package require expect" so that I don't have to worry
about the path to the .so file?
| |
| Gerald W. Lester 2007-04-30, 4:17 am |
| Tom Conner wrote:
> I installed ActiveTcl8.4.14.0 and, as usual, it has everything and the
> install was painless. However, I have one question regarding packages and
> other libs. Everything, except for Expect, I just "package require <package
> name>". Expect I use
> load <path to expect .so>/libexpect.so
>
> Is there any way to "package require expect" so that I don't have to worry
> about the path to the .so file?
Sure, just use the correct package name:
(
glester) 50 % package require Expect
5.43
--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
| |
| Bezoar 2007-04-30, 4:17 am |
| On Apr 29, 9:35 pm, "Tom Conner" <tcon...@olopha.net> wrote:
> I installed ActiveTcl8.4.14.0 and, as usual, it has everything and the
> install was painless. However, I have one question regarding packages and
> other libs. Everything, except for Expect, I just "package require <package
> name>". Expect I use
> load <path to expect .so>/libexpect.so
>
> Is there any way to "package require expect" so that I don't have to worry
> about the path to the .so file?
use the caplitalized Expect:
package require Expect
If you find you cannot load an extension then check to see if it has a
pkgIndex.tcl file. Usually
this is under one of the directories found in the $auto_path list.
Tcl will look in all the directories in
the auto_path variable recursively for all pkgIndex.tcl files to
determine what the packages are available
and how to load them. Open up expect's pkgIndex.tcl file and you will
see that the package is Expect.
The convention is to use to caplitalize the first Letter.
Carl
| |
| Tom Conner 2007-04-30, 4:17 am |
|
"Gerald W. Lester" <Gerald.Lester@cox.net> wrote in message
news:JLcZh.57115$cJ1.14298@newsfe13.lga...
> Tom Conner wrote:
and[color=darkred]
<package[color=darkred]
worry[color=darkred]
>
> Sure, just use the correct package name:
> (
> glester) 50 % package require Expect
> 5.43
>
Duh. Who wrote that post? My evil twin?
Thanks.
| |
| Larry W. Virden 2007-04-30, 8:23 am |
| On Apr 29, 10:35 pm, "Tom Conner" <tcon...@olopha.net> wrote:
> Is there any way to "package require expect" so that I don't have to worry
> about the path to the .so file?
Figuring out what kind of case that the developer used for an
extension is one of the challenges of the community. I tend to do
this:
$ tclsh
% package require Tryit
can't find package Tryit
% package require tryit
can't find package tryit
% package require TryIt
can't find package TryIt
% ^D
$ cd /path/where/I/Installed/tryit
$ less pkgIndex.tcl
and then I look to see if I can figure out what name is being used.
The ones that always get me are bwidgets (which for some reason is
BWidget) and tclx (which is Tclx, but which has the man page of TclX).
| |
| Uwe Klein 2007-04-30, 8:23 am |
| Larry W. Virden wrote:
> On Apr 29, 10:35 pm, "Tom Conner" <tcon...@olopha.net> wrote:
>
>
>
>
> Figuring out what kind of case that the developer used for an
> extension is one of the challenges of the community. I tend to do
> this:
>
> $ tclsh
> % package require Tryit
> can't find package Tryit
> % package require tryit
> can't find package tryit
> % package require TryIt
> can't find package TryIt
> % ^D
> $ cd /path/where/I/Installed/tryit
> $ less pkgIndex.tcl
>
> and then I look to see if I can figure out what name is being used.
> The ones that always get me are bwidgets (which for some reason is
> BWidget) and tclx (which is Tclx, but which has the man page of TclX).
>
>
>
>
Hmm:
package require givdatnich
set whatwehave [ package names ]
set whatithinkiwant expect
set found [ lsearch -inline -regexp $whatwehave ***:(?i)$whatithinkiwant ]
puts stderr "required: $whatithinkiwant found : $found"
if {$found != {} } {
package require $found
} else {
puts stderr bahh
}
uwe
| |
| Donal K. Fellows 2007-04-30, 7:09 pm |
| Uwe Klein wrote:
> package require givdatnich
You're doing this to initialize the package loading database? Unless you
already have such a package, you'll have a problem with it if you don't
wrap it in a [catch].
Donal.
| |
| Uwe Klein 2007-04-30, 7:09 pm |
| Donal K. Fellows wrote:
> Uwe Klein wrote:
>
>
>
> You're doing this to initialize the package loading database? Unless you
> already have such a package, you'll have a problem with it if you don't
> wrap it in a [catch].
YES, i missed out on that.
proc loadwhatimean packname {
if {[catch {package require $packname } cerr ]} {
set whatwehave [ package names ]
set found [ lsearch -inline -regexp $whatwehave ***:(?i)$whatithinkiwant ]
puts stderr "required: $packname found : $found"
if {$found != {} } {
return [ package require $found ]
} else {
puts stderr bahh
# error or return -errorcode ..?
}
}
return $cerr
>
> Donal.
uwe
| |
| Uwe Klein 2007-04-30, 7:09 pm |
| Donal K. Fellows wrote:
> Uwe Klein wrote:
>
>
>
> You're doing this to initialize the package loading database? Unless you
> already have such a package, you'll have a problem with it if you don't
> wrap it in a [catch].
YES, i missed out on that.
proc loadwhatimean packname {
if {[catch {package require $packname } cerr ]} {
set whatwehave [ package names ]
set found [ lsearch -inline -regexp $whatwehave ***:(?i)$packname ]
puts stderr "required: $packname found : $found"
if {$found != {} } {
return [ package require $found ]
} else {
puts stderr bahh
# error or return -errorcode ..?
}
}
return $cerr
>
> Donal.
uwe
|
|
|
|
|