[19640] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1835 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 28 06:05:33 2001

Date: Fri, 28 Sep 2001 03:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1001671507-v10-i1835@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 28 Sep 2001     Volume: 10 Number: 1835

Today's topics:
        Can't locate loadable objet for moule Tk:Event <ochampag@nortelnetworks.com>
        extracting the Palm data <tm@kernelconsult.com>
        GetSharedResources problem <gael.cadic@webelites.com>
        grap url <mr.thanquol@gmx.de>
    Re: grap url <ilya@martynov.org>
    Re: grap url <Thomas@Baetzler.de>
    Re: grap url <Thomas@Baetzler.de>
    Re: grap url <mr.thanquol@gmx.de>
    Re: grap url <mr.thanquol@gmx.de>
    Re: grap url <ilya@martynov.org>
    Re: grap url <ilya@martynov.org>
    Re: How to know the script is already running or not??? <hafner@augusta.de>
    Re: install perl module <bart.lateur@skynet.be>
    Re: install perl module <mr.thanquol@gmx.de>
        IO::Socket && IO::Select Problem (NuArb)
    Re: IO::Socket && IO::Select Problem <Thomas@Baetzler.de>
    Re: launching acrobat on Win32 <please@no.spam>
    Re: launching acrobat on Win32 <bart.lateur@skynet.be>
    Re: Managing Child Processes nobull@mail.com
    Re: Not sure what type of cgi script I need! <hafner@augusta.de>
    Re: Not sure what type of cgi script I need! <bart.lateur@skynet.be>
    Re: Not sure what type of cgi script I need! <hafner@augusta.de>
    Re: Push into an array <bill.kemp@wire2.com>
    Re: Running system programs from CGI <Thomas@Baetzler.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 28 Sep 2001 10:18:41 +0200
From: "olivier" <ochampag@nortelnetworks.com>
Subject: Can't locate loadable objet for moule Tk:Event
Message-Id: <9p1bps$sel$1@bcarh8ab.ca.nortel.com>

Hi,

I have installed perl Tk under win NT and all the libraries seem to be
present in the Perl subdirectories architecture, @INC contains also all  the
good path ..

I get the following error when lauching a script using :

Can't locate loadable objet for moule Tk:Event in @INC (......) at
e:\Perl\Site\blib\lib\Tk.pm line 13 ...

what is my mistake .. I think that it is an installation problem because the
script i want to use is a known perl program that works normally fine



Thanks




------------------------------

Date: Fri, 28 Sep 2001 11:47:50 +0200
From: TM <tm@kernelconsult.com>
Subject: extracting the Palm data
Message-Id: <3BB44746.545002B4@kernelconsult.com>

Hi,
I'm trying to extract the content of the Palm databases i.e. Address
Book for instance.
Is there an easy way to do it? Palm::Address doesn't seem to make the
job at least from what I read & tried from the doc.
Maybe a package or an explicit working example is missing 

Thanks


------------------------------

Date: Fri, 28 Sep 2001 10:07:03 +0200
From: "Gael Cadic" <gael.cadic@webelites.com>
Subject: GetSharedResources problem
Message-Id: <9p1cr1$t6k$1@reader1.fr.uu.net>

i am looking for printing all shared resources

my $resources = [];
GetSharedResources($resources, RESOURCETYPE_ANY) || print $^E;
foreach my $href (@$resources){
print fic "-----<br>";
$i++;
print fic "$href<br>";
foreach( keys %$href){
print fic "$_: $href->{$_}<br>";
}
}
print fic "i= ".$i." unités";

the printing end like this

-----
HASH(0x8bb3864)
LocalName:
Comment: Samba Server
Usage: 2
DisplayType: 2
Provider: Réseau Microsoft Windows
RemoteName: \\192.168.0.102
Scope: 2
Type: 0
i= 134 unités

this is not the last server in the LAN
is it a GetSharedResources bug ?

gael




------------------------------

Date: Fri, 28 Sep 2001 10:12:11 +0200
From: "felix" <mr.thanquol@gmx.de>
Subject: grap url
Message-Id: <9p1bcs$6f4$1@crusher.de.colt.net>

hi,

I try to get a URL after I have been forwarded. For example:
    I call http://www.shop.com and I will be forwarded to
https://www.shop.com/buy/more/stuff?SID=807328462304
              ^^^got this
^^ want this to be stored in a variable

would LWP do this job for me?? If yes, how??

thx a lot

fe




------------------------------

Date: 28 Sep 2001 12:45:28 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: grap url
Message-Id: <87n13fd7pz.fsf@abra.ru>

>>>>> On Fri, 28 Sep 2001 10:12:11 +0200, "felix" <mr.thanquol@gmx.de> said:

f> hi,
f> I try to get a URL after I have been forwarded. For example:
f>     I call http://www.shop.com and I will be forwarded to
f> https://www.shop.com/buy/more/stuff?SID=807328462304
f>               ^^^got this
f> ^^ want this to be stored in a variable

f> would LWP do this job for me?? If yes, how??

use LWP::UserAgent;
use HTTP::Request::Common;
use URI;

my $ua = new LWP::UserAgent;
my $uri = 'http://www.shop.com';
my $response = $ua->simple_request(GET $uri);
my $new_uri = URI->new_abs($response->header('Location'), $uri);

Note that if you are using $ua->request instead of $ua->simple_request
you will be automatically forwarded by LWP so you will not be able to
catch 'Location' header of response.


-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


------------------------------

Date: Fri, 28 Sep 2001 11:42:38 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: grap url
Message-Id: <ech8rt42m4578pp0jt3cqgjse6rsc808ok@4ax.com>

On Fri, 28 Sep 2001, "felix" <mr.thanquol@gmx.de> wrote:
>I try to get a URL after I have been forwarded. For example:
>    I call http://www.shop.com and I will be forwarded to
>https://www.shop.com/buy/more/stuff?SID=807328462304
>              ^^^got this
>^^ want this to be stored in a variable
>
>would LWP do this job for me?? If yes, how??

Try the code below. You can track the redirects that happen, too - in
my example, I only care for the final URL.

#!/usr/bin/perl -w

use strict;
use LWP::UserAgent;

# URL below is a redirect to /books/
my $url = 'http://baetzler.de/books.html';

my $ua = new LWP::UserAgent;
my $request = new HTTP::Request('GET', $url );
my $response = $ua->request($request);

if( $response->is_success ){
  my $target = $response->request->uri;
  
  if( $target ne $url ){
    print "You were redirected from $url to $target\n";
  }
}
__END__

HTH,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


------------------------------

Date: Fri, 28 Sep 2001 11:47:20 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: grap url
Message-Id: <cnh8rt450tgk4o1mt2ud96vg1dm7e81e09@4ax.com>

On 28 Sep 2001, Ilya Martynov <ilya@martynov.org> wrote:
>Note that if you are using $ua->request instead of $ua->simple_request
>you will be automatically forwarded by LWP so you will not be able to
>catch 'Location' header of response.

Yeah, you'll have to do it my way, then :-) TIMTOWTDI sure is cool.

Cheers,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


------------------------------

Date: Fri, 28 Sep 2001 11:47:32 +0200
From: "felix" <mr.thanquol@gmx.de>
Subject: Re: grap url
Message-Id: <9p1gvl$958$1@crusher.de.colt.net>


"Ilya Martynov" <ilya@martynov.org> wrote in message
news:87n13fd7pz.fsf@abra.ru...
> >>>>> On Fri, 28 Sep 2001 10:12:11 +0200, "felix" <mr.thanquol@gmx.de>
said:
>
> f> hi,
> f> I try to get a URL after I have been forwarded. For example:
> f>     I call http://www.shop.com and I will be forwarded to
> f> https://www.shop.com/buy/more/stuff?SID=807328462304
> f>               ^^^got this
> f> ^^ want this to be stored in a variable
>
> f> would LWP do this job for me?? If yes, how??
>
> use LWP::UserAgent;
> use HTTP::Request::Common;
> use URI;
>
> my $ua = new LWP::UserAgent;
> my $uri = 'http://www.shop.com';
> my $response = $ua->simple_request(GET $uri);
> my $new_uri = URI->new_abs($response->header('Location'), $uri);
  ^^^^^^^^^^^^^^^line 12 of my script

>
> Note that if you are using $ua->request instead of $ua->simple_request
> you will be automatically forwarded by LWP so you will not be able to
> catch 'Location' header of response.
>
>
why do I get a "missing base argument at test.pl line 12"
sorry for that question, but I don't know the URI.pm and the perldoc doesn't
help me at all...

> --
>  -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> | Ilya Martynov (http://martynov.org/)
|
> | GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6
|
> | AGAVA Software Company (http://www.agava.com/)
|
>  -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-




------------------------------

Date: Fri, 28 Sep 2001 11:56:49 +0200
From: "felix" <mr.thanquol@gmx.de>
Subject: Re: grap url
Message-Id: <9p1hh2$9ed$1@crusher.de.colt.net>


"Thomas Bätzler" <Thomas@Baetzler.de> wrote in message
news:ech8rt42m4578pp0jt3cqgjse6rsc808ok@4ax.com...
> On Fri, 28 Sep 2001, "felix" <mr.thanquol@gmx.de> wrote:
> >I try to get a URL after I have been forwarded. For example:
> >    I call http://www.shop.com and I will be forwarded to
> >https://www.shop.com/buy/more/stuff?SID=807328462304
> >              ^^^got this
> >^^ want this to be stored in a variable
> >
> >would LWP do this job for me?? If yes, how??
>
> Try the code below. You can track the redirects that happen, too - in
> my example, I only care for the final URL.
>
> #!/usr/bin/perl -w
>
> use strict;
> use LWP::UserAgent;
>
> # URL below is a redirect to /books/
> my $url = 'http://baetzler.de/books.html';
>
> my $ua = new LWP::UserAgent;
> my $request = new HTTP::Request('GET', $url );
> my $response = $ua->request($request);
>
> if( $response->is_success ){
>   my $target = $response->request->uri;
>
>   if( $target ne $url ){
>     print "You were redirected from $url to $target\n";
>   }
> }
> __END__
>
> HTH,
> --
> use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
> split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
> '"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
> $_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl

this does the job!!

thx a LOT!

fe




------------------------------

Date: 28 Sep 2001 13:58:52 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: grap url
Message-Id: <87elord4bn.fsf@abra.ru>

>>>>> On Fri, 28 Sep 2001 11:47:32 +0200, "felix" <mr.thanquol@gmx.de> said:

>> use LWP::UserAgent;
>> use HTTP::Request::Common;
>> use URI;
>> 
>> my $ua = new LWP::UserAgent;
>> my $uri = 'http://www.shop.com';
>> my $response = $ua->simple_request(GET $uri);
>> my $new_uri = URI->new_abs($response->header('Location'), $uri);
f>   ^^^^^^^^^^^^^^^line 12 of my script

f> why do I get a "missing base argument at test.pl line 12"
f> sorry for that question, but I don't know the URI.pm and the perldoc doesn't
f> help me at all...

URI->new_abs can die with 'missing base argument' only if
$response->header('Location') returns undef. And it is possible only
if there is no 'Location' header (thus no redirect using 'Location'
header).

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


------------------------------

Date: 28 Sep 2001 14:00:37 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: grap url
Message-Id: <87adzfd48q.fsf@abra.ru>

>>>>> On Fri, 28 Sep 2001 11:47:20 +0200, Thomas Bätzler <Thomas@Baetzler.de> said:

TB> On 28 Sep 2001, Ilya Martynov <ilya@martynov.org> wrote:
>> Note that if you are using $ua->request instead of $ua->simple_request
>> you will be automatically forwarded by LWP so you will not be able to
>> catch 'Location' header of response.

TB> Yeah, you'll have to do it my way, then :-) TIMTOWTDI sure is cool.

Yep. It should also work. However in theory in some cases it is not
feasible to do second request.

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


------------------------------

Date: 28 Sep 2001 09:52:12 +0200
From: Walter Hafner <hafner@augusta.de>
Subject: Re: How to know the script is already running or not???
Message-Id: <qdfg097hhw3.fsf@www.ibexnet.de>

"Dennis" <hkdennis2k@yahoo.com.hk> writes:

> Can I only let the script run one copy only?prevent two or more same script running???
> 

As others have stated: You could use lockfiles. Another way could be to
parse the "ps" output or the "/proc" filesystem, depending on your
operations system (obviously non portable and impossible in Windows).

However, this might be an option if you write something like a daemon
monitor and have to ensure that the process is actually running and
can't rely on a lockfile or pidfile.

-Walter


------------------------------

Date: Fri, 28 Sep 2001 08:12:44 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: install perl module
Message-Id: <dsa8rtk1o7ej7crneasvg62ojit8q3eaje@4ax.com>

eric ng wrote:

>As far as I see, all perl module always has the following file:
>
>Makefile.PL
>xxx.pm (where xxx is the module name)
>
>Is that all perl module installs the same way like follows: 
>perl Makefile.PL 
>make 
>make test
>make install 
>
>Can I just manually copy the xxx.pm file into any of the following
>path -OR- copy to my home dir and use perl -I:
>/usr/local/lib/perl5/5.00503/sun4-solaris
>/usr/local/lib/perl5/5.00503
>/usr/local/lib/perl5/site_perl/5.005/sun4-solaris
>/usr/local/lib/perl5/site_perl/5.005
>
>Why I need to do a make? what's the make does? 

"make" will check all dependencies, and if necessary, do things in the
order they should be done.

And not all modules are that simple. Some are modules based on .xs,
which means they need to be compiled using a C compiler. The compiled
files are very system dependent, that's why they generally need to be
compiled on your system (for Windows, C compilers are not available on
most machines, and since they're so common -- and identical, the modules
come precompiled). "make" takes care of that. And another sort of module
is on that makes use of AUTOLOAD. That implies that the module needs to
be split up into separate files, at the time it's installed. Again,
"make" takes care of that.

Plus, make can run the tests for you. Oh, and you shouldn't do "make
install" if "make test" fails.

But, in the simplest case, indeed, you can just as well manually
install, as you describe. Just don't forget that the module files
needn't always be put at the top level of the directory, which means
you'll have to create one, or some nested, directories, to put the
module file in.

-- 
	Bart.


------------------------------

Date: Fri, 28 Sep 2001 10:14:17 +0200
From: "felix" <mr.thanquol@gmx.de>
Subject: Re: install perl module
Message-Id: <9p1bgq$6fi$1@crusher.de.colt.net>


"eric ng" <m_010@yahoo.com> wrote in message
news:3bb3d19f.31504671@enews.newsguy.com...
> As far as I see, all perl module always has the following file:
>
> Makefile.PL
> xxx.pm (where xxx is the module name)
>
> Is that all perl module installs the same way like follows:
> perl Makefile.PL
> make
> make test
> make install
>
> Can I just manually copy the xxx.pm file into any of the following
> path -OR- copy to my home dir and use perl -I:
> /usr/local/lib/perl5/5.00503/sun4-solaris
> /usr/local/lib/perl5/5.00503
> /usr/local/lib/perl5/site_perl/5.005/sun4-solaris
> /usr/local/lib/perl5/site_perl/5.005
>
> Why I need to do a make? what's the make does?
>
> thanks


I think a cool way to install perl modules is using perl itself!

try this

shell> perl -MCPAN -e 'install <modulename>'
example:
shell> perl -MCPAN -e 'install DBI'

this will download the module from CPAN and interactivly install it!

cheers
fe





------------------------------

Date: 28 Sep 2001 01:36:26 -0700
From: tristan.braun@gmx.net (NuArb)
Subject: IO::Socket && IO::Select Problem
Message-Id: <3dae1176.0109280036.b6a7d90@posting.google.com>

Hi all socket-developers,

I tried to write a chat application. My client is a Java Applet and
the server is written in
PERL.

The server is listening via IO::Socket on Port 2666. The server is
blocking until someone
has something to say or a new connection request. New requests will be
accepted and added to
IO::Select.

The client tries to connect to the server and is starting a thread for
listening on the socket.

Both the java and the perl code works well with some (~10) WS opening
the applet and I thougth
it is on the time to stress the server. I created a MDI VB project and
added a form with the
InternetExplorer Control on it. Per default the Control navigates to
my applet.

I instanciated the page 30 times and the last instance could send a
message. The same with 60.

When I try 90 simultanious connections the connect sucedded for all.
ALL can receive messages.
BUT only the first ~60 Instances can send and the server receives the
message. After closing
any Instances the previously sended message will received by the
server.

The same result is when I startet the VB MDI on two NT boxes with each
have 50 instances.

And when try more than 127 connections + 1 listen my perlserver
crashes.

But in the worst case I will have ~800 users connecting to it !

Here is a snipet of the log I am generating:

IP [fileno]: Message [IO::Select->Count()]

 ...
10.84.39.163[43]: Hello
10.84.39.163[67]: This is a test
10.84.39.163[5]: disconnected [121]
10.84.39.163[6]: disconnected [120]
10.84.39.163[7]: disconnected [119]
10.84.39.163[8]: disconnected [118]
10.84.39.163[9]: disconnected [117]
10.84.39.163[71]: Some other stuff sended previously
10.84.39.163[10]: disconnected [116]
10.84.39.163[11]: disconnected [115]
10.84.39.163[12]: disconnected [114]
10.84.39.163[13]: disconnected [113]
10.84.39.163[14]: disconnected [112]
10.84.39.163[72]: Some other stuff sended previously
10.84.39.163[74]: Some other stuff sended previously
10.84.39.163[75]: Whats up ?
 ...

With netstat -a I receive the following lines:

 The client:
  TCP    myClient:3292         0.0.0.0:0              LISTENING
  ...
  TCP    myClient:3411         0.0.0.0:0              LISTENING

  TCP    myClient:3292         myServer:2666          ESTABLISHED
  ...
  TCP    myClient:3411         myServer:2666          ESTABLISHED

The server:
  TCP    myServer:2666         myClient:3292          ESTABLISHED
  ...
  TCP    myServer:2666         myClient:3411          ESTABLISHED

Here is the server:
- Perl v5.6.1 Binary build 628 provided by ActiveState
- Windows 2000 Server with IIS 5.0

<perl>
use strict;
use IO::Socket;
use IO::Socket::INET;
use IO::Select;
use FileHandle;

my $CHAT = new FileHandle;

$SIG{"INT"} = sub { $CHAT->close; exit 0 };

# Listen-Socket erstellen, das auf eingehende Verbindungen wartet.
my $listen = IO::Socket::INET->new(Proto => 'tcp',
				   LocalPort => 2666,
				   Listen => 256,
				   Reuse => 1) or die $!;

# Listen-Socket in die Select-Tasche stecken, die Anforderungen
überwacht.
my $select = IO::Select->new($listen);

$CHAT->open(">>Chat.txt") || die "Kann die Protokolldatei nicht
öffnen. $!\n";
$CHAT->autoflush;
my @ready;
my @lines;
my %Colors = ();
my %IP = ();
sub cCol {
	return (substr("000" . (int(rand 170) + 30) ,-3))
}

sub Debug {
	my($Text) = @_;
	print $Text;
	print $CHAT $Text;
}

# Warten bis was passiert.
while(@ready = $select->can_read) {

    my $socket;

    for $socket (@ready) {

		# Neue Sockets binden.
		if($socket == $listen) {
			my $new = $listen->accept;
			$select->add($new) if $new;
			$new->send("000000000Willkommen\n" . join('',@lines));
			$IP{$new->fileno} = join('.',unpack("CCCC", $new->peeraddr()));
			Debug ($IP{$new->fileno} . "[" . $new->fileno . "]: connected [" .
$select->count() ."]\n");
			if (not exists $Colors{$IP{$new->fileno}}) 
			{
				$Colors{$IP{$new->fileno}} = cCol . cCol . cCol;
			}
		} else {
			# Nachricht vom Socket auslesen. Wenn nicht klappt, Socket
schliessen.
			my $line="";
			$socket->recv($line,200);
			if($line eq "") 
			{
				Debug ($IP{$socket->fileno} . "[" . $socket->fileno . "]:
disconnected [" . $select->count() ."]\n"); #$socket->fileno . ":
disconnected\n";
				delete $IP{$socket->fileno};
				$select->remove($socket);
				$socket->close;
			} else {
				Debug ($IP{$socket->fileno} . "[" . $socket->fileno . "]: " .
$line);
				$line = $Colors{$IP{$socket->fileno}} . $line;
				push @lines, $line;
				shift @lines if $#lines > 5;

				my $socket;

				# Nachricht an jeden senden. Wenns nicht klappt, Socket
schliessen.
				for $socket ($select->handles) 
				{
					next if($socket==$listen);
					$socket->send("$line") or do 
					{
						print $socket->fileno . ": disconnected\n";		
						$select->remove($socket);
						$socket->close;
					};
				}
			};
		}
	}
}
1;
</perl>

Here is the client:
- Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
- Windows NT 4.0 SP 6a

<java>
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import java.io.*;
import java.net.*;

public class hello extends java.applet.Applet
{
	Font f = new Font("Tahoma", Font.BOLD,11);
	Socket socket = null;
	InputStreamReader isr = null;
	BufferedReader in = null;
	PrintWriter out = null;
	static int iWSize = 7;
	static int iSSize = 100;
	Speicher X = new Speicher(iSSize, iWSize);
	Label lblEingabe = new Label("Message :", Label.LEFT);
	TextField txtEingabe = new TextField(25);
	Button btnSend = new Button("Send");
	Color back = new Color(255,255,240);
	Scrollbar sbv = new Scrollbar();
	Scrollbar sbh = new Scrollbar(Scrollbar.HORIZONTAL,0,25,0,100);

	AdjustmentListener scroll = new AdjustmentListener()
	{
		public void adjustmentValueChanged(AdjustmentEvent e)
		{ repaint(); }
	};

	ActionListener sender = new ActionListener()
	{
		public void actionPerformed(ActionEvent e)
		{
			String sValue = new String(txtEingabe.getText());
			if (sValue != "")
			{
				out.println(sValue);
				out.flush();
				txtEingabe.setText("");
				repaint();
			}
		}
	};

	Thread checker = new Thread()
	{
		public void run()
		{
			boolean OK = true;
			while (OK)
			{
				try
				{
					String Input;
					Input = in.readLine();
					if (Input != null)
					{
						X.Add(Input);
						if (X.Count() > iWSize && X.Count() <= (iSSize - iWSize))
						{
							sbv.setVisibleAmount(100 - X.Count() + iWSize);
							sbv.setValue(sbv.getValue() + 1);
						}
						repaint();
					}
				}
				catch (Exception e)
				{
					X.Add(e.getMessage());
					OK = false;
					try
					{
						socket.close();
					}
					catch (IOException ee)
					{
						X.Add(ee.getMessage());
					}
				}
			}
		}
	};

	public void init()
	{
		setLayout(null);
		setBackground(back);
		setFont(f);

		lblEingabe.setBounds(5,5,60,20);
		add(lblEingabe);

		txtEingabe.addActionListener(sender);
		txtEingabe.setBounds(65,5,210,20);
		add(txtEingabe);

		btnSend.addActionListener(sender);
		btnSend.setBounds(280,5,60,20);
		add(btnSend);

		sbv.addAdjustmentListener(scroll);
		sbv.setBounds(330,25,10,115);
		sbv.setVisibleAmount(100);
		add(sbv);

		sbh.addAdjustmentListener(scroll);
		sbh.setBounds(5,140,325,10);
		add(sbh);

		try
		{
			socket = new Socket(getDocumentBase().getHost(),2666);
			isr = new InputStreamReader(socket.getInputStream());
			in = new BufferedReader(isr);
			out = new PrintWriter(socket.getOutputStream(), true);

			checker.start();
		}
		catch (IOException e)
		{
			X.Add(e.getMessage());
		}
		catch (SecurityException se)  
		{
			X.Add(se.getMessage());
		}
	}

	public void paint(Graphics screen)
	{
		screen.setFont(f);
		X.Rewind(iWSize + (iSSize - sbv.getVisibleAmount() -
sbv.getValue()));
		int i = 0;

		do
		{
			screen.setColor(X.Col());
			screen.drawString(X.Get(sbh.getValue()), 5, 40 + 15 * i++);
		}
		while (X.Next());
	}

	public void stop()
	{
		try
		{
			socket.close();
		}
		catch (IOException ee)
		{
			X.Add(ee.getMessage());
			repaint();
		}
	}

	class Speicher
	{
	//This is only the interface of a class simular to a stack 
		public Color Col()
		public Speicher(int SSize, int VSize)
		public void Add(String Text)
		public String Get(int iStart)
		public int Count()
		public int getCursor()
		public int Pos()
		public void Rewind(int Laenge)
		public boolean Next()
	};
};
</java>

At least the VB MDI:
- Visual Basic 6.0 (SP4)
- Windows NT 4.0 SP 6a

<vb>
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As
Long)

Private Sub MDIForm_Activate()
    Dim x(1 To 60) As Form1
    Dim a As Integer
    Dim b As Integer

    For a = 1 To 60
        Set x(a) = New Form1
        x(a).Left = ((a - 1) Mod 3) * 4400
        x(a).Top = Round((a - 2) / 3, 0) * 3100
        x(a).Show
        x(a).WebBrowser1.Navigate "http://myServer/Java/Applet.htm"
        DoEvents
        Sleep 100
        DoEvents
    Next
End Sub

</vb>

Thanks in advance !

Regards,

Tristan


------------------------------

Date: Fri, 28 Sep 2001 11:00:09 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: IO::Socket && IO::Select Problem
Message-Id: <d1e8rtgpmkjbrfbm60d0qbaal5cdlqcm8i@4ax.com>

On 28 Sep 2001 01:36:26 -0700, tristan.braun@gmx.net (NuArb) wrote:
>The server is listening via IO::Socket on Port 2666. The server is
>blocking until someone
>has something to say or a new connection request. New requests will be
>accepted and added to
>IO::Select.
[...]
>When I try 90 simultanious connections the connect sucedded for all.
>ALL can receive messages.
>BUT only the first ~60 Instances can send and the server receives the
>message. After closing
>any Instances the previously sended message will received by the
>server.
[...]

You may be running against a system limit - the number of file handles
that may be queried in a select() call is limited.

That would also explain the behaviour you're seeing.

HTH,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


------------------------------

Date: Fri, 28 Sep 2001 07:35:03 GMT
From: Andrew Cady <please@no.spam>
Subject: Re: launching acrobat on Win32
Message-Id: <87elor3h3x.fsf@homer.cghm>

"Allan" <clarke__@__hyperformix.com> writes:

> I have been trying to find a way to launch the Acrobat reader to
> view a PDF file. If I use
> 
> system ("test.pdf")
> 
> acrobat comes up but my application hangs until its closed. I have
> not found any variation that works, including

system waits for the started program to finish, and then gives you its
return value.  If you want to start a program in the background, it's
not what you want.

> system ("start test.pdf")
> system ('start','test.pdf')
> system ("cmd.exe /c start test.pdf")
>
> Anyone have any clues on how to start acrobat reader on a file
> without hanging and without explicitly knowing the path to the
> acrobat exe?

Looks like you're trying to get another Windows program to put it in
the background for you.  You may get that to work but it's pretty
clunky.  The proper way in unix would be to fork a child and have it
exec acrobat, but I don't think Windows (or perl for Windows) supports
fork.  You might want to try the Win32::Process module if it works for
your version of Windows, or some other module.  Another option (which
IMO seems even more clunky than system, but if you can't get anything
else to work...) is opening it as a pipe to a filehandle, e.g.

open(HELP_PROC, "start help.pdf|");

HTH.


------------------------------

Date: Fri, 28 Sep 2001 08:43:52 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: launching acrobat on Win32
Message-Id: <l0e8rtcsli38cmlpffnkmp0pfq1e88kr4o@4ax.com>

Andrew Cady wrote:

>The proper way in unix would be to fork a child and have it
>exec acrobat, but I don't think Windows (or perl for Windows) supports
>fork.

It does, through emulation (actually using threads). I don't know
exactly when it was added, likely 5.6.0.

-- 
	Bart.


------------------------------

Date: 28 Sep 2001 02:23:47 -0700
From: nobull@mail.com
Subject: Re: Managing Child Processes
Message-Id: <4dafc536.0109280123.70afab35@posting.google.com>

kschmidt@mindspring.com (Kevin J. Schmidt) wrote in message news:<92541e99.0109261346.3f239018@posting.google.com>...

> 3:  $SIG{CHLD} = \&REAPER;

> 20: foreach $host (sort keys %hostList) {
> 21:   unless ($child = fork()) {
> 22:         # child
> 23:        die "cannot fork: $!" unless defined $child;
> 24:        doSomething();
> 25:        exit;
> 26:    } push @pids, $child;
> 27: }

> Now, if all the children get to the point where they can call exec(),
> then all is well and the parent makes it to line 29 and does its
> thing. If any of the children exit, i.e. they return (due to the host
> being down, etc.) and exit on line 25 is called then the parent never
> makes it to line 29.

Sounds to me like an iteraction between the signal handler and the
main program. I re-iterate more strongly my suggestion that you loose
the handler and simply poll waitpid().

[snip poorly trimmed jeopardy quote]

Please qoute _relevant_ material _in_ context.


------------------------------

Date: 28 Sep 2001 10:11:48 +0200
From: Walter Hafner <hafner@augusta.de>
Subject: Re: Not sure what type of cgi script I need!
Message-Id: <qdfbsjvhgzf.fsf@www.ibexnet.de>

Abigail,

in the past you helped me with several of my questions in this group,
but i have to admit that you became quite rude lately. Maybe time to go
on vacation, eh? ;-)

pilotsnipes@yahoo.com (Snipes) writes:

> >   2) What's got this to do with Perl? So far, you've done zero coding,
> >      and apparently, you need handholding all the way. Perhaps you want
> >      comp.programs.gimme.gimme.gimme.

That's what I mean. The question was polite. I can understand that you
hesitate to give advice to a poster who doesn't seem to know very much
about the topic he's asking about. From my own experience (not in Perl,
but in other fields i know more about) i know that these kind of
questioners tend to expect that you do the whole task for them. :-)

But otoh you simply could have been quiet. No personal offence meant -
i'm just commenting about a behaviour that seems to get more and more
common in this group (c.l.p.misc, that is).

To the OP:

I'd do the following:

- create some kind of simple config file to enter and categorize the
persons you want to send mail to.
- write a simple script that reads the config file and the HTML files
and use it to send the emails (using one of the several mail modules
on CPAN.
- put the script in your crontab

No CGI at all.

Regards,

-Walter


------------------------------

Date: Fri, 28 Sep 2001 08:41:46 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Not sure what type of cgi script I need!
Message-Id: <old8rt0rgmnlml6sd7ol4efo5msrslniie@4ax.com>

Walter Hafner wrote:

>To the OP:
>
>I'd do the following:
>
>- create some kind of simple config file to enter and categorize the
>persons you want to send mail to.
>- write a simple script that reads the config file and the HTML files
>and use it to send the emails (using one of the several mail modules
>on CPAN.
>- put the script in your crontab
>
>No CGI at all.

Except that he might want a web interface for letting the people
subscribe/unsubscribe on different rosters. That would edit  the
database, or as you call it, the config file.

Both to construct the mails with several attachments, and to send the
mail, I'd first look into Mime::Lite.

And, in order to reduce the load on on the SMTP server, group the people
per roster combination, and send it to them all at once: put the
addresses in the Bcc field.

-- 
	Bart.


------------------------------

Date: 28 Sep 2001 11:24:01 +0200
From: Walter Hafner <hafner@augusta.de>
Subject: Re: Not sure what type of cgi script I need!
Message-Id: <qdfy9mzfz2m.fsf@www.ibexnet.de>

Bart Lateur <bart.lateur@skynet.be> writes:

> Except that he might want a web interface for letting the people
> subscribe/unsubscribe on different rosters. That would edit  the
> database, or as you call it, the config file.

Well, if he wants those features (web interface, subscriptions, etc) i'd
install a ready-to-go mailinglist-software. Majordomo or something
similar. :-)

I was under the impression that the recipient list was quite static and
administered at a central place. So i really was thinking of flat files
in a form like:

marketing:John Smith:smith@foo.org
sales:Mike Myers:myers@foo.org
tech,admin:Walter Hafner:hafner@baz.org
 ...

that can easily be parsed by a perl script.

> Both to construct the mails with several attachments, and to send the
> mail, I'd first look into Mime::Lite.

Seconded. I use this module myself, using "lynx" to convert html files
to plain text and sending multipart/alternative mailings in both text
and html.

> And, in order to reduce the load on on the SMTP server, group the people
> per roster combination, and send it to them all at once: put the
> addresses in the Bcc field.

For just a few internal mailings? Sure, it doesn't hurt ...

-Walter


------------------------------

Date: Fri, 28 Sep 2001 10:04:27 +0100
From: "W K" <bill.kemp@wire2.com>
Subject: Re: Push into an array
Message-Id: <_2Xs7.850$t97.9743@news.uk.colt.net>

> && @items = (0 .. 9);
>
>
> Useless use of parenthesis. Parenthesis don't create a list, context does.
>
>     @items = 0 .. 9;

I like parenthesis-es. They help readability and can stop you getting into
trouble sometimes.

It might mean that I have an imperfect grasp of exactly how my code is
interpreted, but sometimes readability is more important than perl purity.

Well it is from where I'm sitting (in a roomful of C programmers).




------------------------------

Date: Fri, 28 Sep 2001 10:00:48 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Running system programs from CGI
Message-Id: <g6a8rtsr24i1nt1lb7c1gbthkdfpu656od@4ax.com>

On Fri, 28 Sep 2001 01:24:05 -0400, "Eric" <stratvio@aol.com> wrote:
>  I'm trying to write a program to register computers to receive dhcp ip's
>and to go through a firewall.  I have the firewall set up such that 1-128 is
>allowed through, and 128 and above is stopped.  Users go to a registration
>page served through apache and enter a system username and password, and are
>then authenticated via PAM.  If they are a real user, the mac address is
>obtained (by pinging their ip and searching "arp -a" for it) and is entered
>in the dhcpd.conf file.  There they are given a static ip under 128.  The
>only thing that isn't working correcty is restarting the dhcp server.  I'm
>trying to just run `/etc/rc.d/init/dhcpd restart`, but it doesn't work and I
>don't get any error messages.

Check the error log of your web server. Your problem is the fact that
daemons such as dhcpd run as root, whereas your web server usually
runs as an unprivileged user like www-data, httpd or even nobody - so
you just don't have the privileges to restart your dhcpd.

Had you tried to run the dhcpd init-script via system, you would have
been able to verify that the program gives you a non-zero return code.

One thing you could do to get this working is to write a small C
program that encapsualtes a system call to the init script in
question. You'd then make that program setuid root and run that
program from your CGI code.

But if I were you, I wouldn't want to do that - because, if you mess
up somewhere, you've created a security hole as wide as a barn door.

What is it you're trying to do, anyways? Apparently you want to allow
some users through your firewall. You collect their credentials via
HTTP, which is in itself a security hole, unless you have a secure
connection established. You then update your dhcp.conf to assign them
a special address. After the dhcpd is restarted, your user must then
release and re-obtain an IP address -  this is clumsy.

As an method to permit/deny Internet access based on the user id, this
doesn't really work well - you can't prevent people from setting their
IP address manually to your NAT'ed address range.

Depending on what you're trying to do, you'd probably fare better if
you just gave everybody a static address assignment via dhcp and
implemented user authentication on proxies for the services you wish
to offer. Squid can do this for http/https, and the TIS firewall
toolkit can do that for ftp. For anything else, you might have to look
at SOCKS.

Or you spend some money for a FW-1 or a similar product that allows
you to base firewall rules on user authentication.

Well, my $0.02
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 1835
***************************************


home help back first fref pref prev next nref lref last post