Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Calling expect through shell

Posted by yateenjoshi (yateenjoshi), 29 August 2005

I am having a tricky problem. I want to locate the expect script with respect to a bundle of programs. I have a shell script where I call expect script. The directory structure is somewhat as follows -
curr_dir/lib/<expectLIBS + tcl8.4dir>

The curr_dir may change from time to time. What I am doing in my shell script (which is in scripts dir) is as follows -

cd ..

export PATH
## Above portion ensures that expect bin and lib are available in future.

Now, the expect script starts with


#This is because I a there in script directory

It seems that this does not work. If I give complete path for expect instead of above, things go smoothly.
The question is, is there any way to resolve this part? I am trying my best to come up with some other solution (and will update it here if I get it). So, please.. help....

Posted by neo (The Architect), 29 August 2005
Are you  trying to get 'expect' to be in your executable path?
or am I missing something?

Posted by admin (Graham Ellis), 29 August 2005
Yateen Yoshi, the words "does not work" fill me with foreboding as they give me no clue as to what may be going wrong.  If you could be more explicit in telling us what goes wrong we would have a better chance of defining and thus solving the problem.  

It might also be a good idea to tell us just why you're trying to set up expect in this way - it's not exactly conventional.  I would suggest that a better approach might be a statically linked executable if you're looking to write a portable application that loads into a single directory stucture and uses expect.  IF that's the case, remember to check the Open Source licenses concerned as you may need to include the source code or take other actions.

Posted by yateenjoshi (yateenjoshi), 30 August 2005
Sorry Graham for not giving the correct description of the problem.
After executing the, I get following error -
./ /home/yjoshi/tempdir/scripts/exp_script.exp: not found

I am sure that shell script is not able to interpret the relative path of finding expect in .exp script and hence gives above error.

Posted by admin (Graham Ellis), 30 August 2005
I suggest you experiment with some simple relative path stuff first if you must have it all in the same tree (you didn't comment on my questioning of this approach, I noticed).   For example, I have created in my current directory a file called dr that contains

echo greeting

With in a file in my jul05 directory called e2 containing a short script (just an echo) it works, but with the file absent it reports a bad interpretter.   Please start with something similar and build up!

Posted by yateenjoshi (yateenjoshi), 30 August 2005
Thanks a lot Graham.
I got where the problem is..)
If we notice the original shell script, I am doing a cd.. there, I need to come to original directory again!!
I did a cd $curr_dir before calling the script and things worked fine. There were no errors. Though I was giving absolute path in calling the expect script, it seems I need to be in the current path to call any program for that matter.

Regarding your question, I have just started with expect and got expect bin and lib from some old project.  It is not 'installed' on any of the machines, so, just wanted to check how the relative paths would work.

Many thanks for your kind help.

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho