Home > Archive > Tcl > May 2004 > Expect fails to load when run from Win service
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 |
Expect fails to load when run from Win service
|
|
|
| We have a script run.tcl which uses Expect by doing a :
package require Expect;
This runs fine on Active TCL and Expect for Windows, when run by hand
at the command prompt, when we say C:\TCL\bin\tclsh.exe run.tcl .
But our intention is to spawn the script from a Windows service when
the service starts. We tried doing this programmatically, by invoking
the tclsh.exe with the script name as an argument, after changing to
the directory where the script resides.
But this time we notice that the TCL shell starts for a brief period
of time and dies immediately. We commented out the package require
Expect; statement and the script started properly , but obviously
failed later when it tried to execute expect commands.
Now that it is established that TCL shell is unable to load the Expect
package when invoked from a service, the question is why?
What should be done to have the script perform correctly.
Could this be because of some environment variables not being set?
Any ideas will be appreciated.
Thanks
| |
| Jeff Hobbs 2004-05-19, 11:32 am |
| Yash wrote:
> We have a script run.tcl which uses Expect by doing a :
> package require Expect;
> This runs fine on Active TCL and Expect for Windows, when run by hand
> at the command prompt, when we say C:\TCL\bin\tclsh.exe run.tcl .
>
> But our intention is to spawn the script from a Windows service when
> the service starts. We tried doing this programmatically, by invoking
> the tclsh.exe with the script name as an argument, after changing to
> the directory where the script resides.
> But this time we notice that the TCL shell starts for a brief period
> of time and dies immediately. We commented out the package require
> Expect; statement and the script started properly , but obviously
> failed later when it tried to execute expect commands.
> Now that it is established that TCL shell is unable to load the Expect
> package when invoked from a service, the question is why?
Hmmm ... good question. One thing that is clear about Windows
services is that you don't have the standard channels available
to you. Can you elaborate on how you established this service
and some short script to reproduce the problem?
--
Jeff Hobbs, The Tcl Guy
http://www.ActiveState.com/, a division of Sophos
| |
| David Gravereaux 2004-05-19, 5:36 pm |
| Jeff Hobbs <jeffh@activestate.com> wrote:
>Yash wrote:
>
>Hmmm ... good question. One thing that is clear about Windows
>services is that you don't have the standard channels available
>to you. Can you elaborate on how you established this service
>and some short script to reproduce the problem?
tclsh doesn't work with srvany (The NT resource kit tool) if that's what
you're using. tclsh will exit when it receives a LOGOFF event.
--
David Gravereaux <davygrvy@pobox.com>
[species: human; planet: earth,milkyway(western spiral arm),alpha sector]
| |
|
| In a script, at the start we have:
if [catch { package require Expect} outcome ] {
set boom [ open "C:\\rock.log" "w" ] ;
puts $boom "$outcome" ;
close $boom ;
}
So if the package require statement fails, a file named rock.log will
be created with the reason of failure listed. Running the script by
hand, we don't find the file created. The rest of the script also runs
well.
When invoked through VB code, using the Shell(<command> ) function,
from a normal program, also makes the script run properly.
Only when we use the same VB code to invoke it from a Win 2000
service, the rock.log file gets created with the following message:
No valid license file found.
To purchase or upgrade a license, or to obtain a free evaluation
license please visit: http://www.ActiveState.com/Products/ASPN_Tcl
Email: Sales@ActiveState.com
Toll-free (North America): 1.866.866.2802
Phone: 604.484.6400
Fax: 604.484.6499
This is the same message one gets if Expect is installed without
installing the license.
We have an evaluation license of Expect installed just 2 days ago.
The problem is not with the package command. We verified this by using
another package like Tcl in the package statement. No errors were
printed.
Another funny thing is that I am able to run the script from the
service on one computer but not on other computers. All PCs have the
Expect version downloaded and installed separately and do not share
the license file.
What might be the reason behind this inexplicable problem?
Thanks
| |
| Jeff Hobbs 2004-05-20, 3:31 am |
| Yash wrote:
> Only when we use the same VB code to invoke it from a Win 2000
> service, the rock.log file gets created with the following message:
> No valid license file found.
...
This is likely because the user that installed the license is not
the same as that which runs the service, thus the license check
fails. Can you verify that?
--
Jeff Hobbs, The Tcl Guy
http://www.ActiveState.com/, a division of Sophos
| |
|
| Jeff Hobbs <jeffh@activestate.com> wrote in message news:<40AC4BF0.5060104@activestate.com>...
> Yash wrote:
> ...
>
> This is likely because the user that installed the license is not
> the same as that which runs the service, thus the license check
> fails. Can you verify that?
You are right. The service ran as LocalSystem account and the license
was installed using my user account.
Thanks a lot.
|
|
|
|
|