Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^5: Redirect expect screen output to file

by u65 (Chaplain)
on Oct 12, 2015 at 12:27 UTC ( #1144524=note: print w/replies, xml ) Need Help??


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:

  • Write a Perl program on the remote host(s) of interest which does all you need. The program should require the login user name of the remote user if that is required.
  • Ensure all persons needing access to the program and the remote hosts have working access via ssh.
  • If the remote program needs to run as root or other privileged user, either make the script setuid or write a wrapper setuid program which will run the required script. Put the script in each user's home directory to be executed via ssh which will run the setuid program. (If you need multiple user access it would probably be easier to put the one or two programs in a group-owned directory.)

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1144524]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2021-05-18 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (176 votes). Check out past polls.

    Notices?