System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

remsh works but not from a script

R.O.
Esteemed Contributor

remsh works but not from a script

Hi,

This command works right:

/usr/bin/remsh host1 "uname -a" :

/usr/bin/remsh host1 "uname -a"
SunOS host1 5.8 Generic_

..but if I execute it from inside a script:

(sleep 2
echo "uname -a"
sleep 2
echo exit
sleep 2 ) | /usr/bin/remsh host1

..it does not work:

Not on system console
Connection closed.

The script works in some systems and does not work in some others... What can be the problem?

Regards,
"When you look into an abyss, the abyss also looks into you"
3 REPLIES
James R. Ferguson
Acclaimed Contributor

Re: remsh works but not from a script

Hi:

What happens if you use the '-n' option>

# remsh host1 -n

See the manpages for 'remsh'.

Regards!

...JRF...
Steven Schweda
Honored Contributor

Re: remsh works but not from a script

> This command works right:

Then perhaps you should use a similar command
in your script, instead of one like:

| /usr/bin/remsh host1

Read:
man remsh

As I understand it, "remsh" does different
things, depending on whether you give it a
command to run. In the "works right" case,
you did. In the "does not work" case, you
didn't. One way, you get a command run. The
other way, you get an interactive session,
which, apparently, runs into more
restrictions.
Mel Burslan
Honored Contributor

Re: remsh works but not from a script

Are you trying to do the poor man's version of "expect" functionality ? Otherwise I do not see any use for this method over running uname -a from a single line of remsh as in

remsh host1 uname -a

The reason you're getting the "Not on system console" messages is, most probably you are trying to login as root using a non-console device (tty/pty of some sort) and some systems are configured NOT TO allow root logins from non-console devices. Actually, it is a very good practice NOT TO let direct root logins from remsh/ssh/rlogin sessions in my opinion.
________________________________
UNIX because I majored in cryptology...