LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 06-23-2009, 11:28 AM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Blog Entries: 1

Rep: Reputation: 90
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, 12:49 PM   #2
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197

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, 09:07 PM   #3
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
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, 12:45 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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, 07:52 AM   #5
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

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

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, 07:40 AM   #7
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
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, 07:03 PM   #8
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
As promised, here it is:

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


Reply

Tags
ssh, streams



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
Standard Input in Perl Program eachow Linux - General 2 11-17-2005 12:16 AM
utf , standard output / input and grep too Fascistchicken Linux - Software 2 11-05-2004 08:52 AM
input/output error when connecting to winXP machine with smbmount andrewgm Linux - Networking 7 03-25-2004 10:07 AM
how to redirecting the standard output in program phil123 Linux - General 3 02-23-2004 12:02 AM
Capturing standard output from external program brianvdc Linux - Software 1 02-12-2003 03:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:35 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