LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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

Reply
 
Search this Thread
Old 09-21-2009, 03:24 PM   #1
murky_
LQ Newbie
 
Registered: Sep 2009
Posts: 2

Rep: Reputation: 1
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.
 
Old 09-21-2009, 04:34 PM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990

Rep: Reputation: 66
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
 
Old 09-21-2009, 07:21 PM   #3
DrLove73
Senior Member
 
Registered: Sep 2009
Location: Srbobran, Serbia
Distribution: CentOS 5.5 i386 & x86_64
Posts: 1,118
Blog Entries: 1

Rep: Reputation: 129Reputation: 129
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?)
 
Old 09-21-2009, 07:51 PM   #4
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
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.
 
Old 09-22-2009, 05:39 AM   #5
murky_
LQ Newbie
 
Registered: Sep 2009
Posts: 2

Original Poster
Rep: Reputation: 1
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
 
  


Reply

Tags
event, handle, ssh


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Keyboard events interrupting mouse events. miner49er Linux - Hardware 3 11-04-2008 04:16 AM
Hang on triggering udev events- is there a buildup of events? sonichedgehog Slackware 20 07-11-2008 02:49 AM
What is the significance of sync events in event handling? montylee Programming 1 05-12-2008 05:14 AM
wxPython: control handling its own events? Hko Programming 1 07-30-2005 06:58 PM
qmail, ssh and events in a LAN Zingaro2002 Linux - Networking 1 08-16-2002 03:50 PM


All times are GMT -5. The time now is 01:22 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 Google+: linuxquestions
Open Source Consulting | Domain Registration