in reply to Re^4: Redirect expect screen output to file
in thread Redirect expect screen output to file

If I understand you correctly, I think I can suggest a more reliable solution, but first please answer these questions:

  1. How many local and remote hosts are involved with use of this script?
  2. Are you the only person to use the hosts?
  3. Is the goal to run a command on the remote host and take actions on the remote host with no logging or side effects to be taken on the local host?

Update: While awaiting your answer, I'll outline my solution which assumes the answer to question three is NO:

With the above you can now do something like this on your local host:

$ ssh user@remotehost progb --arg1=X --arg2=Y

and all will be taken care of on the remote host. I use such a process to update my remote Apache web server which needs root privileges but which does not allow root access via ssh. I use the setuid wrapper script so I can more easily modify the actual script which does all the work and send it to the remote host as an ordinary user. The setuid program doesn't need updating much so the bother of logging in and acting as root doesn't happen very often after the process is working as desired.

Note: wherever I have said "setuid" I believe should be "setgid" for multiple users, but I have no experience with that.