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.


In reply to Re^5: Redirect expect screen output to file by u65
in thread Redirect expect screen output to file by ryalagikar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.