Grabbing info from Telnet


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grabbing info from Telnet
# 1  
Old 03-17-2010
Lightbulb Grabbing info from Telnet

I have a process that is running locally on the machine.

When you telnet to the process: telnet IP port, it automatically returns a string which shows the status of that process.

Something like this:

[user@Server]# telnet IP Port
Trying 127.0.0.1...
Connected to localhost (127.0.0.1).
Escape character is '^]'.
LONGSTRINGOFSTUFF

I want to do grab the info in LONGSTRINGOFSTUFF in a script. Any thoughts?
# 2  
Old 03-18-2010
MySQL

See the following command

Code:
telnet IP PORT  2>file_name

[user@Server]# telnet IP Port
Trying 127.0.0.1...
Connected to localhost (127.0.0.1).
Escape character is '^]'.
LONGSTRINGOFSTUFF

The informations print in STDOUT and STDERR
so I redirect the STDERR only to the file,
(it will redirect the "LONGSTRINGOFSTUFF" into file)
# 3  
Old 03-18-2010
hmmm this doesn't seem to work. It basically creates the file with this:

Trying 127.0.0.1...^M
Connected to localhost (127.0.0.1).^M
Escape character is '^]'.^M


Which has everything except for the information I need.

I am thinking there is probably a way to grab the output of the telnet with the expect command, which I know little to nothing about.
# 4  
Old 03-18-2010
Option 1: Tail the telnet
Code:
$ telnet localhost daytime 2>/dev/null | tail -1
18 MAR 2010 14:33:30 CET

Option 2: Use netcat
Code:
$ netcat localhost daytime
18 MAR 2010 14:33:36 CET

Note: these 2 examples were recorded on a Linux machine
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grabbing variabes from logs

Hey guys, I am working on a script that needs to grab variables from a log file. The script will run morning 9 to 5pm and save variables for each run every hour, these results I will be aggregating at the end of the day. I am thinking I will be placing the date on each entry in the log every... (7 Replies)
Discussion started by: mo_VERTICASQL
7 Replies

2. Shell Programming and Scripting

Want to remove telnet error/info from screen

Hi Team, I am using one script, It is working fine, the problem is it gives unwanted telnet errors when I am using it. I just want to remove these unwanted errors/info from my screen. bash-3.00$ cat raza_site_temp #!/usr/bin/bash #rj835b IFS="|" REGEX="$*" echo snarf2 -c "show... (2 Replies)
Discussion started by: Raza Ali
2 Replies

3. Shell Programming and Scripting

Grabbing strings with awk

Hello everyone, I am doing some sort of analysis for some data about organic solvents, and I have a problem with writing a command to do this: Here's a sample of my file: 1 ethanol 2 methanol 3 methanol/ethanol 4 ethanol/methanol 5 ethanol/DMF 6 ethyl... (6 Replies)
Discussion started by: Error404
6 Replies

4. Shell Programming and Scripting

Inquiry on Grabbing info from file.

Here is another script I am trying to customize currently, this script is used to send me disk space information, but at the moment I have to enter all the servers in manually SERVER= "xxx bbb ccc" ect.. how can I script it so that the servers are called off a txt file versus me entering all... (1 Reply)
Discussion started by: NelsonC
1 Replies

5. Shell Programming and Scripting

Kornshell grabbing value from file

I have a script right now that I run a command which outputs just one word to a file. Well I need to grab that value and use it in another line of code so... touch oraclesid.txt echo $ORACLE_SID > oraclesid.txt #grab that value sqlplus v500/v500@<value> how do I grab that value from the... (6 Replies)
Discussion started by: Blogger11
6 Replies

6. Shell Programming and Scripting

Grabbing Certain Fields

ok, so a script i wrote spits out an output like the below: 2,JABABA,BV=114,CV=1,DF=-113,PCT=99.1228% as you can see, each field is separated by a comma. now, how can I get rid of the first field and ONLY show the rest of the fields. meaning, i want to get rid of the "2,", and... (3 Replies)
Discussion started by: SkySmart
3 Replies

7. UNIX for Dummies Questions & Answers

Help grabbing data of a link

Hi folks; I have a temperature sensor that configured with an IP address so we can open a browser to see the temperatures in our 3 labs all showing in one screen. I'm trying to write a script to call this link then email me the results/output so i don't have to open a browser manually every... (3 Replies)
Discussion started by: Katkota
3 Replies

8. Shell Programming and Scripting

Grabbing variables and comparing

I have two computers with dynamic IP addresses and am using dyndns so that they are identifiable as the same computer even if their IPs change (we'll call them host1.dyndns.com and host2.dyndns.com). I also have a remote server which I would like to store my computers' IP addresses on. There is a... (9 Replies)
Discussion started by: kerpm
9 Replies

9. Shell Programming and Scripting

Webpage to Telnet via Perl and Expect: Telnet problem?

Somewhat long story: I have a simple Perl CGI script that uses Expect to Telnet to a device and grab some data, and then spits it back to Perl for display on the Webpage. This works for many devices I've tried, but one device just fails, it keeps rejecting the password on this device, only... (1 Reply)
Discussion started by: jondo
1 Replies

10. Shell Programming and Scripting

Telnet and get info

Hello all, probably this is a very stupid question but I'm a beginner in the arts of scripting... :confused: I'm trying to do a script that logs in to several equipments, switchs etc, and make them show their version and save all the output to a file. I managed to do the login,... (6 Replies)
Discussion started by: pmpx
6 Replies
Login or Register to Ask a Question