D
Derek Basch
I have a very simple Perl (1) script that calls a bash shell script (2)
and prints the shell STDOUT.
However, It just hangs forever after the shell script (2) returns. I
cannot figure out what I am doing wrong. Any one have an idea?
Here is the Perl script (1):
------------------------------------------------------------------------
open(COMMAND, "$proxy_dir/proxyctl restart |");
while (my $line=<COMMAND>) {
print $line;
};
close(COMMAND);
print "I won't print";
------------------------------------------------------------------------
Here is the bash shell script:
------------------------------------------------------------------------
#!/bin/bash
THEDIR=/home/proxy/
case "$1" in
start)
echo "Starting $THEDIR proxy"
cd $THEDIR
$THEDIR/proxy2 &
;;
stop)
echo "Shutting down $THEDIR proxy"
PID=`/bin/ps auxwww | /usr/bin/grep "$THEDIR/proxy2 -c
$THEDIR/proxy.conf" | /usr/bin/grep -v grep | awk '{print $2}'`
#echo "PID: $PID"
kill $PID
;;
restart)
$0 stop $THEDIR
$0 start $THEDIR
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
and prints the shell STDOUT.
However, It just hangs forever after the shell script (2) returns. I
cannot figure out what I am doing wrong. Any one have an idea?
Here is the Perl script (1):
------------------------------------------------------------------------
open(COMMAND, "$proxy_dir/proxyctl restart |");
while (my $line=<COMMAND>) {
print $line;
};
close(COMMAND);
print "I won't print";
------------------------------------------------------------------------
Here is the bash shell script:
------------------------------------------------------------------------
#!/bin/bash
THEDIR=/home/proxy/
case "$1" in
start)
echo "Starting $THEDIR proxy"
cd $THEDIR
$THEDIR/proxy2 &
;;
stop)
echo "Shutting down $THEDIR proxy"
PID=`/bin/ps auxwww | /usr/bin/grep "$THEDIR/proxy2 -c
$THEDIR/proxy.conf" | /usr/bin/grep -v grep | awk '{print $2}'`
#echo "PID: $PID"
kill $PID
;;
restart)
$0 stop $THEDIR
$0 start $THEDIR
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac