Telnet using shell Scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Telnet using shell Scripting
# 1  
Old 04-27-2012
Question Telnet using shell Scripting

i have written a script as shown below :

Code:
telnet 10.161.240.2 8100
<?xml version="1.0"?> <login_command> <sequence id="1" /> <access  id="1"/> <user name = "user1" password = "pass"/> </login_command> 
<?xml version="1.0"?> <RegistrationDescriptor> <sequence id="1" /> <access    id="1"/> <attributeDescriptors> <action>Register</action> </attributeDescriptors> </RegistrationDescriptor>

when i directly run this commands separately raw data is coming so i want to store that raw data in a text file for which i have this above commands and saved as .sh extension and then tried to run as :
"sh myscript.sh >> mydata.txt"

but then to my data is not getting stored error is coming as:

"Connection closed by foreign host"

Last edited by jim mcnamara; 04-27-2012 at 09:54 AM..
# 2  
Old 04-27-2012
telnet cannot read xml.
try:
Code:
telnet 10.10.101.1 <<EOF
username
password
[command you want execute like ls -l]
[another command here]
exit
EOF

That is called a here document - the EOF .... EOF bit
# 3  
Old 04-27-2012
Hello Jim,

The above logic does work for "ftp" and not "telnet" I guess!

Regards
Ravi
# 4  
Old 04-27-2012
@akrati1
Can you show us a manual session which works? What you post looks like a connection to a website or program which expects you to be using a browser ... but I could be wrong.

@panyam
I agree. You cannot use typeahead to telnet in that manner but there are other Shell techniques which work.


Let's find out if the O/P should be using telnet in the first place.
# 5  
Old 04-27-2012
Is this for some sort of web-based service on an odd port? wget would be a more appropriate tool for that than raw telnet.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Expect scripting telnet stop on bad username or password

I am trying to build and expect script to log into multiple aix boxes and change password. I need for the script to terminate if it cannot log into a server because the username or password is wrong. #!/usr/bin/expect set timeout 1 set host set user set password set uh "Unknown host" set... (3 Replies)
Discussion started by: leemalloy
3 Replies

2. Web Development

Perl scripting or shell scripting?

i am going to study any one of the scripting languages mentioned above(shell 0r perl scripting) . Which is having more scope for a fresher? (1 Reply)
Discussion started by: Anna Hussie
1 Replies

3. What is on Your Mind?

Shell scripting vs Perl scripting

Hi all, I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first. Can you please help me determine which one to... (14 Replies)
Discussion started by: Pouchie1
14 Replies

4. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

5. Shell Programming and Scripting

BASH (or else) scripting for Telnet

Hi everybody, I am thinking on writing a shell script to telnet to Cisco routers, and I am looking for help. I have researched some and could not find much on the topic, or at least much of help anyway... I read "expect" is one solution, but I am looking for something more flexible, as I... (1 Reply)
Discussion started by: ppucci
1 Replies

6. Shell Programming and Scripting

Need Help on Telnet using PERL Scripting

Iam trying to connect to a system through Telnet using net::Telnet Module #!/usr/bin/perl -w use net::Telnet $myPassword = "abcdef"; $telnet = new Net::Telnet ( Timeout=>10, Errmode=>'die'); $telnet->open (10.10.20.00); $telnet->waitfor ('/USERCODE: $/i'); $telnet->print('abc');... (2 Replies)
Discussion started by: sudhakaryadav
2 Replies

7. Shell Programming and Scripting

Shell scripting with Telnet

Hi, im brasilian, sorry for bad english ok? Well, im writing one honeypot, look: #!/bin/bash echo "" echo `cat /etc/welcome.pot` echo "" echo -n "login: "; read usuario echo -n "Password: " #stty -echo read -s senha #stty echo exit Running it in localhost, thats right: ... (1 Reply)
Discussion started by: juniordevil
1 Replies

8. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies

9. UNIX for Dummies Questions & Answers

Telnet FTP scripting

Hi quick question from a unix newbie Working on a project to get me using unix, the point of this project is to find a printer on the network check for jobs in the printer if the printer has no jobs do nothing if the printer has jobs then check the status for errors and e-mail the user. This... (2 Replies)
Discussion started by: w33man
2 Replies

10. UNIX for Dummies Questions & Answers

scripting Telnet

can someone tell me how i can write a shell script that will automatically log me in to any machines i want without bothering me for some password input? (i know i have to put in a password but I would like to take care of that in the script) can anyone help me here? (2 Replies)
Discussion started by: TRUEST
2 Replies
Login or Register to Ask a Question

Featured Tech Videos