script for nested rlogin and telnet


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script for nested rlogin and telnet
# 1  
Old 03-03-2008
script for nested rlogin and telnet

I want to write a script that rlogins to a couple machines and then from the last machine, telnet into a final machine and execute a command. So in pseudocode it would look like:

rlogin host1
from host1 rlogin host2
from host2 telnet host3
from host 3 execute command

The reason for the nesting of the logins/telnet is because host 3 is only available via a telnet from host 2 and host 2 is only available via host 1.

Any ideas on how to accomplish this?? Thanks.
# 2  
Old 03-03-2008
Just a matter of nesting the subshells.
It depends heavily on the exact shell you'd use at each level but something like this:
Code:
rlogin host1 (rlogin host2 (rlogin host 3 (command)))

or
Code:
rlogin host1 rlogin host2 rlogin host3 command

Alternativly, try substituting quotes in place of brackets if the shell doesn't like your syntax.

edit: Oh wait, your need to use telnet on the last hop...
For that, you'll need a .netrc file on host2 pipe into the telnet rather than provide the command as a parameter.
# 3  
Old 03-04-2008
Thanks for the help, but it did not work. I'm trying to get this working piece by piece and am just focusing on rloging into host1 and then from host1 rloging into host2 and cannot get this to work. I've tried:

rlogin host1 (rlogin host2)

rlogin host1 'rlogin host2'

rlogin host1 "rlogin host2"

And it keeps complaining about the rlogin syntax. Any other ideas out there?
# 4  
Old 03-05-2008
Ah, my bad, I was thinking of rsh. Is that an option for you?
# 5  
Old 03-06-2008
I've made some progress. So far I can remsh into host1, then from host1 I can remsh into host2, and then from host2 I can telnet into host3 with this script:

#! /bin/csh

remsh host1 "remsh host2 "telnet host3""

The final hurdle I need to get over is executing a command on host3. I've tried:

remsh host1 "remsh host2 "echo 'command' | telnet host3""

But that didn't even seem to telnet me into host3, I got an error saying "no route to host". If I manually rlogin into host1 and then from there manually log into host2 and execute the command "echo 'command' | telnet host3" it works just as I'd like. I don't get why it can't do it via a script.
# 6  
Old 03-06-2008
It's your quoting, the telnet is trying to run back on host1, it's not getting passed to host 2 as a commandline parameter due to the pipe not being properly escaped into a subshell.

Have a go with " \" ' and ( some more to find what you need to protect the | better.
# 7  
Old 03-19-2009
Wasap guys, kind of the same situation,
how can I design a script to nest to another server and type the user id and password for me.
Ive tried

rlogin HOST |&
sleep $DELAY
print -p $USER
sleep $DELAY--------> 2 sec
print -p UPASS

and Ive tried
rlogin host -l <user>
and it takes me to the server but still asks for the password.


we dont have ssh installed
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to eliminate files .rlogin

Hi guys, I'm try making to script for eliminate files rlogins. path1='/home/*' for i in `cat /etc/passwd |awk -F: '{print $6}'`; do if test "$i" = "$path1"; then echo $i cd $i if ; then echo "$i/.rhosts detectado"|mail -s "rhosts" root ... (14 Replies)
Discussion started by: nena_redbalon
14 Replies

2. Shell Programming and Scripting

rlogin and script

I am writing a script to do rlogin to another system and execute commands on the remote system, i can successfully login to the remote system but the commands are not sent. i can only use rlogin to get to the remote system. what can i do? (6 Replies)
Discussion started by: aydj
6 Replies

3. Shell Programming and Scripting

rlogin and telnet

I want to make a script which will execute a command from a remote server like below rlogin server1 then telnet server2 (username, password will be given) now execute command (it may "ls -l *.txt") and give the output I've to do this manually but want to make it automatic Script may... (4 Replies)
Discussion started by: shoeb
4 Replies

4. Shell Programming and Scripting

Nested Case in UNIX script

Hi I wanted to know if we can write a nested case in UNIX script. Something like following - Case ${sDB} in Srvr1) case ${sSchema} Sch1) DBusr=Username1 DBPwd=Pwd1 ;; Sch2) DBusr=Username2 ... (1 Reply)
Discussion started by: sumeet
1 Replies

5. IP Networking

rlogin,telnet-different or same?

Hai guys, Both "rlogin" and "telnet" are used to login remote host.Is there any differece between these 2 commands? (or) are both same? Thanks (1 Reply)
Discussion started by: Felicia23
1 Replies

6. Solaris

rlogin, telnet connections timeout

Hi, I have a Sun Ultra 5 desktop with Solaris 8. When I telnet/rlogin into any other host, the connection closes after few hours of inactivity. I also have another Windows box which I use rarely. But when I telnet/rlogin into the same hosts using putty, the connection stays for days without any... (5 Replies)
Discussion started by: dr_gsb
5 Replies

7. Shell Programming and Scripting

rlogin inside a c-shell script

Hi Forumers, Sorry if it's really simple, but I couldn't find a way out. :( I've to do something like this in a script (csh): <some commands, variable settings, scripts> rlogin different_server <some commands, variable settings, scripts> After "rlogin", it shows the prompt of the... (5 Replies)
Discussion started by: sumitgarg
5 Replies

8. Shell Programming and Scripting

rlogin from Shell script

I am logged into an AIX Unix box. From there I want to remotely login to remotely login to an HP-UX Unix box and want to execute a command that will create a file. I want to get the file to the AIX box. Can someon eplease advise how to automate that in a shell script? At the first step I want to... (2 Replies)
Discussion started by: asutoshch
2 Replies

9. UNIX for Dummies Questions & Answers

telnet, rlogin, ssh login probblem

Hello Friends, I had an IRIX box won't let me login with any IDs (even root) Telnet, Rlogin, SSh. However, I can login by single user with root ID. Telnet login >>> Connection closed by forgeign host. Rlogin >>> Connection closed SSh login >>> connection to address ???.????.???.??? ... (1 Reply)
Discussion started by: anphdula
1 Replies

10. UNIX for Dummies Questions & Answers

rlogin & telnet

hi what is the main difference between rlogin and telnet? Or they are synonymous cheers (13 Replies)
Discussion started by: g-e-n-o
13 Replies
Login or Register to Ask a Question