1821801 Members
3049 Online
109637 Solutions
New Discussion юеВ

remote command execution

 
SOLVED
Go to solution
John Carver
Frequent Advisor

remote command execution

I need to execute a custom command on a remote machine. remsh seems to be the most likely command but I think I am running into the terminal issue mentioned in the man page. If I telnet to the remote host, everything works fine and I get a formatted output. Is there another command to use? Also a question about the execution environment. When you use remsh for a specific user, does the command run in the environment of that user?
3 REPLIES 3
Theresa Patrie
Regular Advisor

Re: remote command execution

It would help to know what you are trying to do remotely. The environment used by remsh is not the same as the environment on the original machine. A simple way to show this would be to add a path to an executable to your $PATH on the local machine, then try to run the same command using remsh.
I think remsh is usually the way to go. You must specify absolute paths to non-system commands (I usually specify the complete paths to system commands as well). If it is output you are not seeing on the screen, maybe you need to re-direct the output to a file.
Theresa
This is my easy job!
Bill Hassell
Honored Contributor
Solution

Re: remote command execution

remsh does not login like telnet. Therefore, nothing in /etc/profile or .profile is run so the environment is nothing like a telnet connection.

remsh is typically used as a batch command to gather information or to kick off some process remotely (ie, remsh remote-cpu bdf), but as the man page suggests, it doesn't work for interactive commands like vi. And if the application expects to see a terminal with fancy features, you'll have to export that on the command line something like this:

remsh remote-cpu export TERM=hpterm /path/to/appicaltion optional-parameters...


Bill Hassell, sysadmin
John Carver
Frequent Advisor

Re: remote command execution

The ability of this process to run had everything to do with setting up the proper environment. I took the relevant lines from /etc/profile and the users .profile and created a new file to be read before execution.
I redirected the standard out to /dev/null since the program that will launching this does not need this information. Now the results
are the same as if the user on the remote machine had run this directly.

remsh nimbus -l poller '. /optim/bin/.remsh_env;/optim/bin/OptimExtract --modules=product > /dev/null'

Thanks to all for pointing me in the right direction.