LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 04-22-2009, 07:09 PM   #1
visitnag
Member
 
Registered: Mar 2008
Posts: 147

Rep: Reputation: 15
telnet to other system and do some job automatically....


Hi all,

I want a solution for automatic telnet. I want to get a file from other system after doing some operation on the file. Suppose i want to cut some characters and zip it.. from that particular file and get that cutfile.bz2. I can get the file with ftp with automatic process..but i dont want the whole file. How to do? The other system may not allow ssh. Help me....
 
Old 04-22-2009, 09:34 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by visitnag View Post
Hi all,

I want a solution for automatic telnet. I want to get a file from other system after doing some operation on the file. Suppose i want to cut some characters and zip it.. from that particular file and get that cutfile.bz2. I can get the file with ftp with automatic process..but i dont want the whole file. How to do? The other system may not allow ssh. Help me....
"How to do"?? Write a program to do it. Either do it in bash, using "expect", or do it in Perl, using CPAN telnet modules.

Once you connect, you'll have to parse the STDIN input, and act on it accordingly....what have you written so far?
 
Old 04-23-2009, 05:07 AM   #3
jisjis
LQ Newbie
 
Registered: Apr 2009
Posts: 18

Rep: Reputation: 0
Quote:
Originally Posted by visitnag View Post
Hi all,

I want a solution for automatic telnet. I want to get a file from other system after doing some operation on the file. Suppose i want to cut some characters and zip it.. from that particular file and get that cutfile.bz2. I can get the file with ftp with automatic process..but i dont want the whole file. How to do? The other system may not allow ssh. Help me....

Write an application (using Java/C++/etc) to do the business logic bit (cutting and zipping files) and then invoke a shell script to do the FTP'ing bit.

Voila!


Linux

Last edited by jisjis; 04-26-2009 at 04:35 AM.
 
Old 04-23-2009, 06:27 AM   #4
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Rep: Reputation: 107Reputation: 107
Smile

Hi,

You can expect for this.

For eg. you have a file called telnet.sh and other file login

Code:
#!/usr/bin/expect -f
set host [lindex $argv 0]
set rcfile [open $host r ]
gets $rcfile user
gets $rcfile pass
spawn telnet "$host"
expect "login:"
send "$user\r"
expect "word:"
send "$pass\r"
interact
Login file contains
Code:
root
Password123 (you password)

Now,

Code:
telnet.sh login
run your commands here
Also, I request moderators to move this thread to Programming.

Last edited by vikas027; 04-23-2009 at 06:30 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Telnet automatically every 15 minutes cgcamal Programming 4 11-26-2008 12:06 PM
Cron job to automatically to runlevel 1 or disconnect al logged on users foramgoram Ubuntu 4 06-12-2008 01:07 PM
ssh/telnet coonecting and dropping automatically? bkpuser Linux - Newbie 1 12-18-2007 07:07 AM
A ksh script to connect to telnet automatically? bijit1709 Programming 3 04-11-2007 11:30 PM
cron job to execute automatically lifegamer Linux - Newbie 2 09-16-2006 08:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 06:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration