LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-16-2006, 12:57 PM   #1
gauge73
Member
 
Registered: Jan 2003
Location: Dallas, TX
Distribution: Fedora Core 4
Posts: 420

Rep: Reputation: 30
Need some resources about IPC


Hey all,

I'm wanting to do a little side project for work in which I will need to use interprocess communication. I'd like to write it as either a perl script, bash script, or a C++ program. I'd prefer that it was one of the latter two. Can anyone give me some hints on where I should be looking for information about how to pipe information back and forth between processes? One of the main things I'll need to be able to do is to have my control process (the bash script, perl script, or C++ program) control a telnet session.

Any help would be greatly appreciated. Thanks in advance!
 
Old 11-16-2006, 02:06 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
AFAIK, no standard telnet package has any ability to read/write IPC queues, shared memory, or semaphores; at least not for the purpose of communicating with other applications.

I will hazard a guess that you want to create a scheme where your software replaces the actions of a human operator typing into and viewing a telnet session. I have accomplished some very simple-minded arrangements like that, using GNU screen to contain a running telnet session (actually, I prefer Kermit), and a perl script that grabs from the screen session and stuffs characters into the session. It is a major hack, as you may have guessed.

There is the program expect, which may address your situation. Perhaps someone well acquianted with it can add some useful comment on it.

Given how simple telnet itself is, you may find it easier and probably much cleaner to write some TCP code into your overall application, to perform the network side of the job. This might be beyond bash scripting, but certainly not perl or C++.

--- rod.
 
Old 11-16-2006, 06:29 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
That def sounds like a Perl job to me, although I guess it depends on which lang you know best.
I wouldn't try it in bash though.
For Perl you'll need to look at search.cpan.org to get the modules which will do all the heavy lifting for you.
Another good resource is http://www.perlmonks.com/
 
Old 11-16-2006, 07:07 PM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
If you need to control a telnet session programmatically, consider using expect. Expect was originally bound to the TCL language, but I think there are bindings to perl and python.

Expect lets you spawn a process with a pseudo terminal, and then watch the output of that process, and according to that output, emulate terminal input by sending commands. You can even control multiple processes, decide at some point to connect them to the actual user's terminal etc.

Expect can be used to automate long processes where different commands are issued according to the output of previous ones. This is very useful in testing environments.

Another typical use for expect is to administrate multiple machines, e.g.taking a list of 100 machines, logging into each one in turn, issuing some commands (e.g. adding a new user account), logging out and moving to the next machine. Although there are already tools to perform this sort of mass-admin, using expect gives you more flexibility than many of them.

While you can automate logins, it's not generally considered a good idea for expect to send the passwords itself. It is tempting, but this sort of thing should really be eliminated (by using ssh and public key authentication). There are times however when it's still necessary.
 
Old 11-17-2006, 07:02 AM   #5
gauge73
Member
 
Registered: Jan 2003
Location: Dallas, TX
Distribution: Fedora Core 4
Posts: 420

Original Poster
Rep: Reputation: 30
Thanks for all the great responses, guys.

What I'm wanting to do is to exchange some SMTP commands with a mail server (which I do manually using telnet). Is there a way I could incorporate all the network interaction into a C++ program without having to bother with IPC and telnet?

I was in hopes that there would be some standard way to simply redirect the input and output of any process to/from another process thus allowing a bash script, perl script, or C++ program to control just about anything. I guess I had my hopes a bit high.
 
Old 11-17-2006, 07:07 AM   #6
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Quote:
Originally Posted by gauge73
Thanks for all the great responses, guys.

What I'm wanting to do is to exchange some SMTP commands with a mail server (which I do manually using telnet). Is there a way I could incorporate all the network interaction into a C++ program without having to bother with IPC and telnet?

I was in hopes that there would be some standard way to simply redirect the input and output of any process to/from another process thus allowing a bash script, perl script, or C++ program to control just about anything. I guess I had my hopes a bit high.
Expect will do exactly what you want.
 
Old 11-17-2006, 09:46 AM   #7
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by gauge73
What I'm wanting to do is to exchange some SMTP commands with a mail server (which I do manually using telnet). Is there a way I could incorporate all the network interaction into a C++ program without having to bother with IPC and telnet?

I was in hopes that there would be some standard way to simply redirect the input and output of any process to/from another process thus allowing a bash script, perl script, or C++ program to control just about anything. I guess I had my hopes a bit high.
You can do almost anything you want over a TCP network in C++, but it is probably easier in perl. There are many perl modules already written to do the low-level network stuff. You would just have to drop the right one(s) in, and wrap your application around it. A search on cpan.org, for SMTP, turned up tons of relevant hits.

After skimming through the expect man page, it really looks like that might be the way to go, too. This would seem to fit your desire to use the 'one program controls another program' scenario.

--- rod.

Last edited by theNbomr; 11-17-2006 at 09:47 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
IPC problem saturndude Mandriva 2 07-01-2006 09:50 AM
IPC question... climbingmerlin Programming 4 11-03-2005 03:30 AM
about IPC iclinux Programming 1 01-14-2005 11:16 PM
Semaphores and IPC gsu_790 Programming 2 09-29-2004 09:29 AM
IPC Mechanisms ananthbv Programming 5 12-20-2003 11:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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