C
clqrq
Hi there, i'm a little bit stuck with my programm and need help, so
let me reduce it to the problem...
I have two skripts; the first does the following:
It saves the Process-ID ($$) to a file and enters a loop, waiting for
Strings.
The second shall read the PID from file and till here, everything is
fine. Now, skript #2 shall send a string (lets say $test='Hallo' to
Skript #1 and wait for reply. What I dont understand is:
How can Skript #2 send a string to Skript #1?
How can Skript #1 get the String.
- - -
#!/usr/bin/perl
#####################################
The First Skript
#####################################
if (open(BS,'>','../server.pid')) {
print BS $$;
close BS;
}
#
# here we need a loop, checking for incoming messages
# and processing strings, then returning them to sender
# - one special message shall break the loop
#
exit;
- - - -
#!/usr/bin/perl
#####################################
The Second Skript
#####################################
$test='hallo';
if (open(BS,'<','../server.pid')) {
$Server-PID=<BS>;
close BS;
}
print &CallServer($Server-PID,$test);
exit;
sub CallServer {
my $answer=''; # the answer of the server
my $SPID=$_[0]; # servers PID
my $Message=$_[1]; # Message to send
#
# here we need a way to send $$ and one or
# more strings to $Server-PID, waiting for response
#
return $answer;
}
let me reduce it to the problem...
I have two skripts; the first does the following:
It saves the Process-ID ($$) to a file and enters a loop, waiting for
Strings.
The second shall read the PID from file and till here, everything is
fine. Now, skript #2 shall send a string (lets say $test='Hallo' to
Skript #1 and wait for reply. What I dont understand is:
How can Skript #2 send a string to Skript #1?
How can Skript #1 get the String.
- - -
#!/usr/bin/perl
#####################################
The First Skript
#####################################
if (open(BS,'>','../server.pid')) {
print BS $$;
close BS;
}
#
# here we need a loop, checking for incoming messages
# and processing strings, then returning them to sender
# - one special message shall break the loop
#
exit;
- - - -
#!/usr/bin/perl
#####################################
The Second Skript
#####################################
$test='hallo';
if (open(BS,'<','../server.pid')) {
$Server-PID=<BS>;
close BS;
}
print &CallServer($Server-PID,$test);
exit;
sub CallServer {
my $answer=''; # the answer of the server
my $SPID=$_[0]; # servers PID
my $Message=$_[1]; # Message to send
#
# here we need a way to send $$ and one or
# more strings to $Server-PID, waiting for response
#
return $answer;
}