Calling expect through shell
Posted by yateenjoshi (yateenjoshi), 29 August 2005Hi,
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 -
## 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 2005Are you trying to get 'expect' to be in your executable path?
or am I missing something?
Posted by admin (Graham Ellis), 29 August 2005Yateen 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 2005Sorry Graham for not giving the correct description of the problem.
After executing the shell_script.sh, I get following error -
./shell_script.sh: /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 2005I 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
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 2005Thanks 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.
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: firstname.lastname@example.org • WEB: http://www.wellho.net • SKYPE: wellho