Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
09-21-2009, 03:24 PM
|
#1
|
|
LQ Newbie
Registered: Sep 2009
Posts: 2
Rep:
|
Handling events over ssh
Hello,
I have probably a little odd question, but hope I've chosen the most appropriate forum and I would get some advice here.
I have an access to a remote machine which runs FreeBSD. I connect there via ssh and run there some program (instant messenger). IM can run and execute any python script except script opening a new socket.
And here is my problem. I want to run some script on my local machine (e.g. play a sound) when some event occur on the remote machine (new message arrival). And the only connection which I have is the ssh connection (cant open new socket on remote machine and my local one is behind NAT). Is there any way to handle such event?
Alternatively I was looking how to stream audio over ssh what would also solve my problem but I don't think it's a best and most effective solution (while I could get the same result by sending only a few bytes instead of many kilobytes).
Thanks in advance,
David
Last edited by murky_; 09-21-2009 at 03:29 PM.
|
|
|
|
09-21-2009, 04:34 PM
|
#2
|
|
Senior Member
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990
Rep:
|
Try getting your IM client to run a simple Python script that just logs a message to standard out. Hopefully, that message should get sent to the standard output of the IM client, which in turn will be passed over SSH - then it's just a matter of parsing the SSH client's standard output client-side.
If the IM client redirects the script's output, then you may have to do something else to pass the message along. You can create a named pipe on the BSD machine, then when you connect, run the IM client in the background (add an "&" to the end of the command-line). Then cat the named pipe in the ssh session. You can then have your python script write a line of text to the named pipe when the message arrives. http://en.wikipedia.org/wiki/Named_p..._pipes_in_Unix
The client-side processing should be fairly easy. Once you have the message-sending working, you can just pipe the output of ssh into a python script (add "|/path/to/script" to the command-line), and then use that to play your sound when a message arrives.
Hope that helps,
–Robert J Lee
|
|
|
|
09-21-2009, 07:21 PM
|
#3
|
|
Senior Member
Registered: Sep 2009
Location: Srbobran, Serbia
Distribution: CentOS 5.5 i386 & x86_64
Posts: 1,115
Rep: 
|
If you are running same script on your local machine, maybe you can send a message from remote IM to local IM, bypassing ssh session all together?
Also, if I rememmber correctly, SSH can redirect/forward desired ports so you can have something like mini network inside SSH tunnel. If I do rememmber correctly, then maybe you could create server-client connection between local and remote host (maybe even direct IM?)
|
|
|
|
09-21-2009, 07:51 PM
|
#4
|
|
Senior Member
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 2,962
Rep: 
|
Are you able to tunnel X via ssh? At least then you could open multiple terminals. Can you ssh back to your own machine.
Kevin Barry
Last edited by ta0kira; 09-21-2009 at 07:53 PM.
|
|
|
|
09-22-2009, 05:39 AM
|
#5
|
|
LQ Newbie
Registered: Sep 2009
Posts: 2
Original Poster
Rep:
|
Thank you a lot for all answers. I think port forwarding is exactly what I was looking for. Now I just need to write a program listening on a given port on my local machine and use remote forwarding by typing 'ssh -R{remote_port}:localhost:{local_port} {remote_address}'
If someone has similar problem, here I found a great tutorial on that: http://docstore.mik.ua/orelly/networ...sh/ch09_02.htm
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 09:32 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|