LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 06-23-2009, 12:28 PM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,379
Blog Entries: 1

Rep: Reputation: 60
Question Connecting both standard input and output to another program so that they can interac


Hi!

I need to use SSH to connect to a host (a router, to be exact) but then I want to develop an application that can handle the session for me (it should send commands to the router and receive the output of those commands), in other words, I need to connect the standard output of this handler program to the stdin of the SSH client and the standard output of the SSH client to the handler's standard input.

Is there a way to do this?

Thanks in advance.
 
Old 06-23-2009, 01:49 PM   #2
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,183

Rep: Reputation: 105Reputation: 105
Well, it's a slightly different approach than you might have been thinking, but you might want to take a look at Expect http://expect.nist.gov/ . You can write in it directly (it is based on tcl), you can call it from perl, you can use it with ssh connections. Check out the FAQ. The book is good (I have a copy and have used it fairly extensively).
 
Old 06-24-2009, 10:07 PM   #3
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Etch/Lenny/Squeeze
Posts: 3,340

Rep: Reputation: 286Reputation: 286Reputation: 286
Expect is good for these kind of things. However have you considered talkng to your router in snmp? Most settings and readings, if not all, in a router are available through SNMP.

jlinkels
 
Old 06-25-2009, 01:45 AM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 5.7, Solaris 10
Posts: 10,994

Rep: Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752
Another alternative is Perl using the Net::SSH http://search.cpan.org/~ivan/Net-SSH-0.09/SSH.pm, or Net::SSH::Expect http://search.cpan.org/~bnegrao/Net-...SSH/Expect.pod or Net::SSH::Perl http://search.cpan.org/~turnstep/Net...et/SSH/Perl.pm module.
 
Old 06-25-2009, 08:52 AM   #5
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,379
Blog Entries: 1

Original Poster
Rep: Reputation: 60
Well... I kept myself in the "bash" spectrum through the use of named pipes.
 
Old 06-25-2009, 07:30 PM   #6
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,183

Rep: Reputation: 105Reputation: 105
Share the details. Someone will find it useful. How did you do it? What were the steps? How did it work?
 
Old 06-26-2009, 08:40 AM   #7
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,379
Blog Entries: 1

Original Poster
Rep: Reputation: 60
I know.. that's the next step. I'll blog about it (expect to get it by the weekend) and then I'll link here. Fair enough?
 
Old 06-28-2009, 08:03 PM   #8
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,379
Blog Entries: 1

Original Poster
Rep: Reputation: 60
As promised, here it is:

http://maratux.blogspot.com/2009/06/...-separate.html
 
  


Reply

Tags
ssh, streams


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Standard Input in Perl Program eachow Linux - General 2 11-17-2005 01:16 AM
utf , standard output / input and grep too Fascistchicken Linux - Software 2 11-05-2004 09:52 AM
input/output error when connecting to winXP machine with smbmount andrewgm Linux - Networking 7 03-25-2004 11:07 AM
how to redirecting the standard output in program phil123 Linux - General 3 02-23-2004 01:02 AM
Capturing standard output from external program brianvdc Linux - Software 1 02-12-2003 04:20 AM


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

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration