in reply to simple IPC needed

Since you talked about Tk maybe somthing like this would work. I have not fiddeld with Tk for some time but I hope I got the important stuff correct here.

Sending prog:
use Tk; my $mw = MainWindow->new(); $mw->send('Foo' => $file_name);


Receiving prog:
use Tk; my $main_window = MainWindow->new(-title => 'My other prog'); $main_window->appname('Foo'); MainLoop; sub Tk::Receive{ shift; my $string = shift; if ($string =~ /pattern/){ # Do somthing. } else { die 'Wrong arg Received'} }

Replies are listed 'Best First'.
Re^2: simple IPC needed
by redss (Monk) on Feb 18, 2005 at 13:21 UTC
    That looks like exactly what I need - I'll play with it later and let you know. thanks!
Re^2: simple IPC needed
by redss (Monk) on Feb 18, 2005 at 16:06 UTC
    Yes this is exactly what I need. Thanks! I haven't been able to get it working though, as I've never done anything in Tk before.

    The second program runs fine, but when running the first program, it says "Failed to AUTOLOAD 'MainWindow::send" (under windows) or "send to non-secure perl/Tk application rejected" (under linux).

    I found this in the perl/tk FAQ:

    the script that receives from a Tk::send must run with taint
    checking turned on (i.e. with the -T switch thrown) and 
    it must untaint all commands received from the other process. 
    
    Apparently this error has to do with me not untainting my data? I tried running the scripts with -T, but its still not working. I'm a newbie to this tainting concept.

    Any idea of how to get around this problem?

      Here are two progs that works under linux, I have no way to test under windows. You should read "perldoc perlsec" for info about security and tainted data. You untaint data with regexps, remember to be careful.
      #!/usr/bin/perl -w use strict; use Tk; my $mw = MainWindow->new(); my $file_name = 'Some file'; $mw->send('Foo' => $file_name); #!/usr/bin/perl -Tw use strict; use Tk; my $main_window = MainWindow->new(-title => 'My other prog'); $main_window->appname('Foo'); MainLoop; sub Tk::Receive{ shift; my $string = shift; if (my ($file) = $string =~ /^([^-]+)$/){ print "Got: $file\n"; exit 0; } else { print "Wrong arg Received\n"; exit 1; } }