The process you should see is the bash process with the child process for the expect, so that part presumably works as expected.
If i understand you correctly, the problem is, that the command run in the cron
won't get executed as it should.
While you speak in general terms without concrete example of what you are trying to do
and what in that fails, I can only give a few ideas of what might have gone wrong.
- Is the line in crontab set up correctly? Especially what comes to my mind is that is the
user root or something else? Apparently you want to run this script as root.
- Does the wrapper-script work iif you run it interactively from the shell (as the direct calling of expect works)? If it doesn't, fix the script so that it works.
About the environment variables and other initialization in the startup scripts:
- When run from the cron, blocks that are contained between the 'if [ "$PS1" ]; then' and 'fi' are not executed.
- exporting of BASH_ENV doesn't work as you migth expect. The shell script named there is ran only for subsequent shell calls (there are none because 'expect' is not a shell script but a c-program). If you want to contain the environment setup in /root/.bashrc, you can do it by command 'source /root/.bashrc'.
- How have you got yourself to root in the first place when you have tested the command? If you do sudo or su, some of the environment variables are inherited from the invoking user account. use 'sudo su -' or 'su -' to get a shell without environment from the invoking user [and see if it the original script still works].