Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Playing a sound on a remote computer

Status
Not open for further replies.

astin

MIS
Jun 20, 2002
87
GB
Hello

Im running 2 windows machines with perl installed...i would like to run a script on one windows box to inform the OTHER windows box to play a sound file. Can this be done using perl - and if so, how would I go about doing it. I've looked up the Perl Reference guides but can only see examples for playing sounds locally.

thanks
A
 
The target machine would probably have to have something running to be looking for commands to play a sound from the other machine.

If both machines are connected to a network, you could use IO::Socket (or POE::SocketFactory) to run a server/client instance. One computer would run a server on a certain port and the other computer would connect to that port.

Then the two processes could communicate through the socket, so the Perl process on the invoking machine can send a message to the Perl process on the target machine, instructing it to play a sound.

There may be other modules for doing something similar, I vaguely recall a module with a name like Win32::pipe for opening pipes between computers on a network, which is sorta similar. You'd have to look that up though.
 
If you have a webserver running you could use LWP::Simple to pass values from one machine to the other ...

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
thanks for your help - is there anywhere where i can see some example code - can't see what im looking for on cpan.

A
 
The webserver would be your 'local' machine in that it's the one you want to play sounds on, for example file.cgi takes the param1 and param2 and depending on the variables plays a sound

Code for script on client pc
Code:
use LWP::Simple;
 $content = get("[URL unfurl="true"]http://webserver/file.cgi?param1=x&param2=y");[/URL]
 die "Couldn't get it!" unless defined $content;
code for file.cgi
Code:
#!/usr/bin/perl
use CGI;
$q=new CGI;
if ($q->param('param1') eq x) {
   &play ($q->param('param2');
}
sub play {
  ($var) = @_;
  # do what you have to to play a sound
}

HTH
--Paul

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top