How to auto telnet the server from another server?


 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions How to auto telnet the server from another server?
# 1  
Old 05-25-2011
How to auto telnet the server from another server?

Hi All,
I have a problem with auto telnet script, but I want to tell u something
a) I am only a member access on the server, so not able to access 'root' account
b) not able to install any software on server
3) On server, there is not install 'except'

1. The problem statement, all variables and given/known data:
I have to write a script, which is ran from A server, login/telnet to B server, do 'ls -lrt' and send to me the output via mail.


2. Relevant commands, code, scripts, algorithms:
I have only basic stucture....
** run from Server A
1) login to B
2) cd landing path
3) ls -l > a.txt
4) mail -s "Status" user@domain.com < a.txt
5) connection closed


3. The attempts at a solution (include all code and scripts):
Code:
telnet ServerB
echo user
sleep 1
echo password
sleep 1
cd landing_zone
ls -l > output.txt
mail -s "status" user@gmail.com < outout.txt
echo exit



4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Gautam Budh technical university
Uttar Pradesh
India
Mr. Nanhey Singh
Inderprastha Engg Collegesyllabus/CS_IT_b_tech_3_4_year.pdf

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

Last edited by pludi; 05-25-2011 at 05:45 AM..
# 2  
Old 05-26-2011
The best way to do this is with expect, and you can record an expect script with autoexpect. There are expect features in bash, as well. However, your attempt to get by with sleep is OK if fragile. You need to collect all the stdout with () and pipe it into telnet stdin.
Code:
(
echo user
sleep 1
echo password
sleep 1
cd landing_zone
ls -l
) | telnet . . . | mailx . . . .

No file needed.
# 3  
Old 05-26-2011
Hi DG
Thanks for help, but the problem is ... this ls -l output... the o/p which I got via mail is mine on SERVER A, not from SERVER B ..... Smilie

Server A
Code:
ls 
a b c d

Server B
Code:
ls 
p q r s


so I can login on B via script, want the ls of SERVER B, but I got the ls from Server A

I got this o/p

Code:
ls 
a b c d

# 4  
Old 05-28-2011
Quote:
Originally Posted by atul9806
Hi DG
Thanks for help, but the problem is ... this ls -l output... the o/p which I got via mail is mine on SERVER A, not from SERVER B ..... Smilie
Yes, that's because you have to pipe things into telnet, it reads from standard input, it doesn't just magically take lines that happen to be below it.
# 5  
Old 05-29-2011
is there a way to do like what I want ???? please help ...
# 6  
Old 05-29-2011
Quote:
Originally Posted by atul9806
is there a way to do like what I want ???? please help ...
If you need to enter a password into telnet, you'll pretty much have to use the expect language.

Do you really need to use telnet? why not ssh?
# 7  
Old 05-30-2011
Quote:
Originally Posted by Corona688
If you need to enter a password into telnet, you'll pretty much have to use the expect language.

Do you really need to use telnet? why not ssh?
On my server . there is not install except and I have to do telnet/ssh, can you please help me to write a ssh script which can able to do so ???

thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Cybersecurity

Web Server Allows Password Auto-Completion

Hi, After running 'nessus' tool to find the Vulnerability in server OS - RHEL 5 we got " Web Server Allows Password Auto-Completion (PCI-DSS variant)" link for description provided by tools - report Nessus Plugins | Tenable Network Security I have checked - Their is only... (1 Reply)
Discussion started by: saurabh84g
1 Replies

2. Shell Programming and Scripting

how do I infinite loop (reconnect) to auto disconnect telnet server

I want the text based Star Wars movie at towel.blinkenlights.nl to loop infinitely. It plays the movie and then disconnects my session? Can anyone think of a way to make my unix machine automatically reconnect over and over? EDIT no commands are required are the connection its just in and... (3 Replies)
Discussion started by: herot
3 Replies

3. Homework & Coursework Questions

How to auto telnet the server from another server

Hi All, I have a problem with auto telnet script, but I want to tell u something a) I am only a member access on the server, so not able to access 'root' account b) not able to install any software on server 3) On server, there is not install 'except' 1. The problem statement, all variables... (0 Replies)
Discussion started by: atul9806
0 Replies

4. Shell Programming and Scripting

How to auto telnet the server from another server using script

Hi All, I have a problem with auto telnet script, but I want to tell u something a) I am only a member access on the server, so not able to access 'root' account b) not able to install any software on server 3) On server, there is not install 'except' I have to write a script, which is ran... (0 Replies)
Discussion started by: atul9806
0 Replies

5. Solaris

Sun Server auto ping to 0.0.0.0

Hi All, 3 of my SAP sun server are continuosly pinging to the network address 0.0.0.0. I have no idea how this can happen, but they have something in common. All of them are clustered environment (Veritas Cluster). Anyone can help? rgds, (5 Replies)
Discussion started by: ronny_nch
5 Replies

6. Ubuntu

Problem to auto mount on NFS server

I am new in Ubuntu and i use Ubuntu 7.10, and have problem to mount automatic when i reboot computer, Here is my /etc/fstab 192.168.0.91:/home/DATA/it /home/USER/usertest/Documents/Z nfs defaults 0 0 I try many option in that line, but the result is same, I cannot automatic mounting the... (5 Replies)
Discussion started by: blesets
5 Replies

7. Programming

Auto FTP from UNIX to Windows Server

Hi, I am a not strong programmer and now my boss ask me how should I do a job to automated FTP that have error check. I know about: * using system() to call a command to trigger ftp in C Coding. The senarios as follows: 1. FTP the file(s) (e.g ELA_20060407.dat) to a given LAN server... (1 Reply)
Discussion started by: songtam
1 Replies

8. Shell Programming and Scripting

Auto FTP to a server

Hi, I am trying to automate FTP login to a remote server and put a file there. But no matter what i do, It still is aksing me for the login and password although i have it defined in the variable. Could you tell me what is wrong with this script. I am doing this on SUN server. Pls... (11 Replies)
Discussion started by: systemali
11 Replies

9. UNIX for Dummies Questions & Answers

Sun solaris server auto reboots

Hi Guys, For the past month, our sun solaris server has rebooted itself 3 times. The sysadmin is saying that is not a sun issue and does not want to carry out any further research with sun about that. The db logfile does not show anything about any db issues at that time. I opened an oracle TAR... (3 Replies)
Discussion started by: mnjanje
3 Replies
Login or Register to Ask a Question