[28170] in Perl-Users-Digest
Perl-Users Digest, Issue: 9534 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 28 14:05:54 2006
Date: Fri, 28 Jul 2006 11:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 28 Jul 2006 Volume: 10 Number: 9534
Today's topics:
Re: Bug in Perl Profiler? <simon.chao@fmr.com>
Re: getopts::std <uri@stemsystems.com>
Re: How to find all files in a directory with a specifi <rvtol+news@isolution.nl>
libwww-POST Issue <azstyx@yahoo.com>
libwww-SSL UserAgent Post Issue <azstyx@yahoo.com>
Re: libwww-SSL UserAgent Post Issue <rvtol+news@isolution.nl>
Odd output from regex. <sunckell@gmail.com>
Re: Odd output from regex. <mritty@gmail.com>
Re: Odd output from regex. <1usa@llenroc.ude.invalid>
Re: Odd output from regex. <sunckell@gmail.com>
Old output from regex. <sunckell@gmail.com>
Re: Old output from regex. <mritty@gmail.com>
Re: Old output from regex. <sunckell@gmail.com>
Re: Questions about (non-blocking) sockets <spam.trap.never.read@mailinator.com>
Re: Questions about (non-blocking) sockets xhoster@gmail.com
Strange characters using Term::Readline on Win32 <w.n.humann@agilent.com>
Re: Strange characters using Term::Readline on Win32 <1usa@llenroc.ude.invalid>
Re: Strange characters using Term::Readline on Win32 <jue@monster-berlin.de>
Sybase connection error <nmrabinovich@gmail.com>
Re: Text descriptions of signal codes? anno4000@radom.zrz.tu-berlin.de
Re: The "proper name" for the series: foo, bar, etc <contact.morrison@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 Jul 2006 06:23:58 -0700
From: "it_says_BALLS_on_your forehead" <simon.chao@fmr.com>
Subject: Re: Bug in Perl Profiler?
Message-Id: <1154093038.936388.132950@s13g2000cwa.googlegroups.com>
xhoster@gmail.com wrote:
> "it_says_BALLS_on_your forehead" <simon.chao@fmr.com> wrote:
> > xhoster@gmail.com wrote:
> > > "it_says_BALLS_on_your forehead" <simon.chao@fmr.com> wrote:
> > > > It seems that something about the way the Perl profiler gathers
> > > > information from my script is breaking my code. The errors are
> > > > inconsistent, both in type, and location.:
> > > >
> > > > bash-3.00$ alias
> > > > alias prof='perl -d:DProf'
> > > > alias tmon='dprofpp'
> > > > bash-3.00$
> > > >
> > > > bash-3.00$ prof fork_titan.pl
> > >
> > > Based on the name of your program, I seems likely that it forks. It
> > > would not suprise me at all if forking and DProf were incompatible and
> > > led to bizarre behavior. Any chance you can create a dummy program
> > > without forking and profile that?
> >
> > Good suggestion, I hadn't thought of that. Will do it when time permits
> > and post the info. Thanks Xho.
>
> I ran a simple forking program under 5.8.0 and 5.8.8, with and without
> DProf. I never saw the "not a CODE ref" error, but I did see some instances
> in which the *child* process seg-faulted. Segfaults only occured under
> 5.8.0 and then only in conjunction with DProf. (Could the error messages
> you saw be coming from a child?) Anyway, I'd recommend an upgrade.
Yeah, I agree that a Perl upgrade would be a smart move, unfortunately
red tape can be a sticky barrier to that path. *shrug* I've voiced that
suggestion; I'll see how that goes. Thanks for taking the time to help
test Xho.
------------------------------
Date: Fri, 28 Jul 2006 11:52:52 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: getopts::std
Message-Id: <x7vephsp4b.fsf@mail.sysarch.com>
>>>>> "a" == anno4000 <anno4000@radom.zrz.tu-berlin.de> writes:
a> Uri Guttman <uri@stemsystems.com> wrote in comp.lang.perl.misc:
>> >>>>> "u" == usenet <usenet@DavidFilmer.com> writes:
>>
u> Paul Lalli wrote:
>> >> Please don't use the word "null" when talking about Perl to beginners.
>>
u> You're right. I should have said "empty." Or, maybe, "ain't got
u> nuthin' in it"
>>
>>
>> IMO null string is also an acceptable term but empty string is better for
>> newbies.
a> "Null string" would be clear enough, but without qualification "null"
a> should only be used when the context provides a definition. Perl
a> context doesn't, so saying "$x is null" is ambiguous.
oh, i agree with you, hence my mention of null string and not null.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Fri, 28 Jul 2006 15:14:44 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: How to find all files in a directory with a specific mtime
Message-Id: <ead9lp.1i8.1@news.isolution.nl>
schms schreef:
[Don't top-post. Don't quote signatures nor disclaimers nor other tails.
Read the Posting Guidelines, that are posted here twice a week.]
> Dr.Ruud:
>> schms:
>>> I have to write a perl program which finds all files in a directory
>>> with mtime (modification time)
>>> of "today - 8 days" ( e.g. today is: 27.7.06, -8 days is: 19.7.06,
>>> so the file's modification
>>
>> [code]
> Your approach is totally new for me. I am going to study this.
Revision, to make it look less daunting:
#!/usr/bin/perl
use strict ;
use warnings ;
use IO::All ;
use constant Days => 8 ;
my $filter = sub{my $m = -M $_->name; Days <= $m and $m <= Days+1} ;
my $path = "$ENV{HOME}/dev/perl" ;
for (sort {$b->mtime <=> $a->mtime}
io($path)->filter($filter)->all_files)
{
printf "%s%8d%6.1f %s\n"
, $_->uid
, $_->size
, -M $_->name
, $_->filename
}
(IO:All doesn't have "mtime_days" yet...)
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 28 Jul 2006 10:29:32 -0700
From: "AZSTYX" <azstyx@yahoo.com>
Subject: libwww-POST Issue
Message-Id: <1154107772.156432.58870@b28g2000cwb.googlegroups.com>
Hello Folks!
Environment:
libwww-perl: 5.805
OS: Solaris 8
Perl: 5.8.4
Issue Summary:
Issue with posting form variables in POST operation using
HTTP::REQUEST.
I have a script that sends a form via POST with one form element
'DownloadFormat=ascii'.
I first wrote the script using pure UserAgent POST and all works fine.
However, I tried (just for a learning experience) to utilize
HTTPS::Request method
and I have an unexplained issue.
According to the lwpcook.pod, they give an example:
HTTP::REQUEST example format:
[code]
my $req = HTTP::Request->new(POST =>
'http://www.perl.com/cgi-bin/BugGlimpse');
$req->content_type('application/x-www-form-urlencoded');
$req->content('match=www&errors=0');
my $res = $ua->request($req);
[/code]
UserAgent POST example format:
[code]
my $req = POST 'http://www.perl.com/cgi-bin/BugGlimpse',
[ search => 'www', errors => 0 ];
print $ua->request($req)->as_string;
[/code]
In reviewing this info, I see that the author is passing the form
variables and
values in the ::REQUEST via the $req->content(). I am not understanding
this call
of why the form varaibles would be passed in the content section?
Especially in
the next example when they use the variable 'search" and in the first
example
they use the variable 'match' (I guess thats another question?)
The only way I was able to get the script to work properly was to code
the
single form variable and value ('DownloadFormat=ascii') in the URL as:
https://10.10.10.10:1954/dynamic/File/Configuration/ReceivefromDevice?DownloadFormat=ascii
AND I also HAD TO specify something (didn't seem to matter what) in the
content() method.
To make it work I used some garbage text: $httpReq->
content('Comment=justacomment') ;
Q: Why did I have to pass my form variable and value like I would if I
was doing a GET,
when I am doing a form POST operation?
(I prefixed my URL with '?DownloadFormat=ascii').
Q: What is the proper method using HTTP::REQUEST to pass form
variables and values when
doing a POST operation?
Q: Why did I have to specify something in content(), even though it
was just garbage code?
($httpReq-> content('Comment=justacomment') ;)(It would not work
otherwise!)
My script:
[code]
#!/export/ieapps/common/perl5/perl-5.8.4/bin/perl
# getwsd3.pl - LWP demo - downloads a radware WSD config ascii file.
# utilizes HTTPS and login credentials, https request object
# interfacing with https request object is depreciated form
# usage: lwpdemo.pl <devname> <devipaddr> <port> <uid> <passw>
# output: /export/ieapps/local/test/<devName.asc>
use strict;
use warnings;
use LWP;
#############################################
my $urlConfigFile = '/dynamic/File/Configuration/ReceivefromDevice' ;
my $urlDeviceinfo = '/dynamic/Device/DeviceInformation';
my ($ua, $httpReq, $httpResp, $url, $baseUrl, $credUrl, $strReq);
my ($devName, $devIP, $port, $UID, $upassw);
my ($statusLine, $statusCode, $statusMsg, $contentResponse);
my $asciiFile = "/export/ieapps/local/test/";
#################################################
if (@ARGV == 5) { # if there are 5 arguments
$devName = $ARGV[0];
$devIP = $ARGV[1];
$port = $ARGV[2];
$UID = $ARGV[3];
$upassw = $ARGV[4];
}
else {
die "Error 01: Usage: $0 <devname> <devipaddr> <port> <uid>
<passw>\n";
}
print "Processing devName [$devName] ip addr [$devIP].\n";
print "Using libwww-perl-$LWP::VERSION\n";
$asciiFile .= "$devName.asc";
print "Output file is [$asciiFile].\n";
$baseUrl = "https://$devIP:$port"; # create base URL
$credUrl = "$devIP:$port"; # create URL for credentials
print "Base URL [$baseUrl]\n";
#######################################################################
# start LWP Processing
#########################################################################
$ua = LWP::UserAgent->new; # create new user agent object
$ua->timeout(15); # set user agent timeout to 15 seconds
$url = "$baseUrl$urlConfigFile?DownloadFormat=ascii"; # create URL for
getting config ascii file
# set up HTTP REQUEST object
$httpReq = HTTP::Request->new(POST=>$url) ; # init Request object
$httpReq-> content_type('multipart/form-data') ; # content type/mode
$httpReq-> content('Comment=justacomment') ; # content garbage to make
it work
$httpReq-> authorization_basic($UID, $upassw) ; # credentials
$strReq = $httpReq->as_string( );
print "\nThe Request:\n$strReq\n";
print "\n\nNow get the WSD config ascii file.\n";
print "Submitting browser request using url [$url].\n";
$httpResp = $ua->request($httpReq) ;
$statusLine = $httpResp->status_line();
$statusCode = $httpResp->code();
$statusMsg = $httpResp->message();
print "HTTP Response: StatusLine[$statusLine] Code[$statusCode]
Message[$statusMsg]\n";
if ($httpResp->is_success) {
print "Request OK.\n";
}
else {
die "Request failed.\n";
}
# ok, save content to file
open(FILEO, ">$asciiFile") || die "Error $! Could not open file
$asciiFile.\n";
print FILEO $httpResp->content;
close(FILEO);
[/code]
The run results:
[code]
dsysadm03z>./getwsd3.pl device-y 10.10.10.10 1900 admin admin
Processing devName [device-y] ip addr [10.10.10.10].
Using libwww-perl-5.805
Output file is [/export/ieapps/local/test/device-y.asc].
Base URL [https://10.10.10.10:1900]
The Request:
POST
https://10.10.10.10:1900/dynamic/File/Configuration/ReceivefromDevice?DownloadFormat=ascii
Authorization: Basic aWVhZG1pbjptMWdodHkhTTB1czM=
Content-Type: multipart/form-data
Comment=justacomment
Now get the WSD config ascii file.
Submitting browser request using url
[https://10.10.10.10:1900/dynamic/File/Configuration/ReceivefromDevice?DownloadFormat=ascii].
HTTP Response: StatusLine[200 OK] Code[200] Message[OK]
Request OK.
dsysadm03z>
[/code]
Appreciate any feedback anyone may have to offer!!!
:)
styx
------------------------------
Date: 28 Jul 2006 10:31:15 -0700
From: "AZSTYX" <azstyx@yahoo.com>
Subject: libwww-SSL UserAgent Post Issue
Message-Id: <1154107875.694039.71480@b28g2000cwb.googlegroups.com>
Hello Folks!
Environment:
libwww-perl: 5.805
Crypt::SSLeay -- 0.51
OS: Solaris 8
Perl: 5.8.4
Issue Summary:
Issue with SSL UserAgent POST operation.
I have a script that randomly fails against devices using HTTPS, which
have a known Certificate issue.
In repeated runs against the same host, it fails just about every other
time (every 2nd run).
It is fact that the host certificate needs to be re-generated with
proper hostname and ip address.
(We are currently ignoring these warnings when using IE browser to
access the host).
With the CA issue in mind, I suspect that the bad certs are what is
making the program fail.
I receive these types of messages:
StatusLine[500 Server closed connection without sending any data back]
Code[500] Message[Server closed connection without sending any data
back]
StatusLine[500 EOF] Code[500] Message[EOF]
Q: With that said, does LWP have a method of verifying a host Cert or
SSL issue?
Q: How can I debug this issue since it is not consistent?
Q: Is there another CPAN module I can use to check and validate the SSl
connection or certificate?
My script:
[code]
#!/export/ieapps/common/perl5/perl-5.8.4/bin/perl
# getwsd2.pl - LWP demo - downloads a radware WSD config ascii file.
# utilizes HTTPS,login credentials and writes directly to external
content file.
# usage: lwpdemo.pl <devname> <devipaddr> <port> <uid> <passw>
# output: /export/ieapps/local/test/<devName.asc>
use strict;
use warnings;
use LWP;
#############################################
my $urlConfigFile = '/dynamic/File/Configuration/ReceivefromDevice' ;
my $urlDeviceinfo = '/dynamic/Device/DeviceInformation';
my ($ua, $httpReq, $httpResp, $url, $baseUrl, $credUrl);
my ($devName, $devIP, $port, $UID, $upassw);
my ($statusLine, $statusCode, $statusMsg, $contentResponse);
my $asciiFile = "/export/ieapps/local/test/";
#################################################
if (@ARGV == 5) { # if there are 5 arguments
$devName = $ARGV[0];
$devIP = $ARGV[1];
$port = $ARGV[2];
$UID = $ARGV[3];
$upassw = $ARGV[4];
}
else {
die "Error 01: Usage: $0 <devname> <devipaddr> <port> <uid>
<passw>\n";
}
print "Processing devName [$devName] ip addr [$devIP].\n";
print "Using libwww-perl-$LWP::VERSION\n";
$asciiFile .= "$devName.asc";
print "Output file is [$asciiFile].\n";
$baseUrl = "https://$devIP:$port"; # create base URL
$credUrl = "$devIP:$port"; # create URL for credentials
print "Base URL [$baseUrl]\n";
#######################################################################
# start LWP Processing
#########################################################################
$ua = LWP::UserAgent->new; # create new user agent object
$ua->timeout(15); # set user agent timeout to 15 seconds
$url = "$baseUrl$urlDeviceinfo"; # set full url for device info
print "Setting Credentials using credurl[$credUrl]\n";
$ua->credentials($credUrl,"Radware",$UID => $upassw);
print "\n\nNow get the WSD config ascii file.\n";
$url = "$baseUrl$urlConfigFile"; # create URL for getting config ascii
file
print "Submitting browser request using url [$url].\n";
$httpResp = $ua->post($url, [DownloadFormat => 'ascii'],
':content_file' => $asciiFile); # save memory, write directly
to file
$statusLine = $httpResp->status_line();
$statusCode = $httpResp->code();
$statusMsg = $httpResp->message();
print "HTTP Response 2: StatusLine[$statusLine] Code[$statusCode]
Message[$statusMsg]\n";
if ($httpResp->is_success) {
print "Request OK.\n";
}
else {
die "Request failed.\n";
}
[/code]
My run results:
[code]
dsysadm03z>./getwsd1.pl device-b 10.10.10.20 1900 admin admin
Processing devName [device-b] ip addr [10.10.10.20].
Using libwww-perl-5.805
Output file is [/export/ieapps/local/test/device-b.asc].
Base URL [https://10.10.10.20:1900]
Setting Credentials using credurl[10.10.10.20:1900]
Submitting initial browser request using url
[https://10.10.10.20:1900/dynamic/Device/DeviceInformation].
HTTP Response 1: StatusLine[200 OK] Code[200] Message[OK]
Request OK.
Results:
Now get the WSD config ascii file.
Submitting browser request using url
[https://10.10.10.20:1900/dynamic/File/Configuration/ReceivefromDevice].
HTTP Response 2: StatusLine[500 EOF] Code[500] Message[EOF]
Request failed.
[/code]
I appreciate any comments or feedback on my issue!!
:)
Styx
------------------------------
Date: Fri, 28 Jul 2006 19:44:40 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: libwww-SSL UserAgent Post Issue
Message-Id: <eadq04.198.1@news.isolution.nl>
AZSTYX schreef:
> $ua->timeout(15); # set user agent timeout to 15 seconds
Did you test with 30 or 60?
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 28 Jul 2006 06:39:43 -0700
From: "sunckell" <sunckell@gmail.com>
Subject: Odd output from regex.
Message-Id: <1154093983.709458.129940@i3g2000cwc.googlegroups.com>
Hello everyone,
I am getting some strange output from a regex. Wondering if anyone
can see what I am doing wrong. I am on a Solaris 8 server, running
perl 5.8
sub process_measurements{
my $cmd = "/usr/ucb/ps -auwwx";
my @trbl_pids;
open PS, "$cmd |" or die "Cannot open $cmd:$!\n";
while(<PS>){
next if /^USER/;
/^
(\w+) # user of process -- 1
\s+
(\d+) # pid of process -- 2
\s+
(\w+\.\w) # cpu percentage of process -- 3
\s+
(\w+\.\w) # memory percentage -- 4
\s+
(\w+) # virtual memory size -- 5
\s+
(\w+) # resident size of process -- 6
\s+
(\?|\w+\/\w+) # associated tty -- 7
\s+
(\w) # state of process -- 8
\s+
(.*) # start, time, and command -- 9
$/x or do
{
# this occurs when %MEM SZ ans RSS are wider than
# the column width and runs together. Which means
# they are higher usage processes. Will account
# for these separately.
warn "WARNING: line not in processable format:
$_\n";
my $user = $1;
my $pid = $2;
my $cpu = $3;
print "$pid $cpu $user\n";
push(@trbl_pids, $pid);
next;
}
}
close (PS);
print "TROUBLE: @trbl_pids\n";
}
Basically all I am doing is reading a ps output. When I print $user
and $pid I only get the first letter\digit of the field.
For example if root owns a process, I only get the letter r when I
print $user, where I should get root.
Anyone see my mistake, or am I over looking something in reading the
output?
Thanks,
sunckell
------------------------------
Date: 28 Jul 2006 06:47:37 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Odd output from regex.
Message-Id: <1154094457.420844.228320@m79g2000cwm.googlegroups.com>
sunckell wrote:
> [The same question he just posted]
Please don't do that. Usenet is not instanteous. Not seeing your
posted message immediately is not cause for posting the same message
again.
Paul Lalli
------------------------------
Date: Fri, 28 Jul 2006 13:50:29 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Odd output from regex.
Message-Id: <Xns980E64349B60Casu1cornelledu@127.0.0.1>
"Paul Lalli" <mritty@gmail.com> wrote in news:1154094457.420844.228320
@m79g2000cwm.googlegroups.com:
> sunckell wrote:
>> [The same question he just posted]
>
> Please don't do that. Usenet is not instanteous. Not seeing your
> posted message immediately is not cause for posting the same message
> again.
I guess he corrected the subject line (s/old/odd), rather than being
impatient. However, Paul's advice still applies. There is no need to
create a separate thread just for such a simple correction. When
corrections are warranted, you should still post them in the same thread.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: 28 Jul 2006 06:52:39 -0700
From: "sunckell" <sunckell@gmail.com>
Subject: Re: Odd output from regex.
Message-Id: <1154094759.643808.88790@b28g2000cwb.googlegroups.com>
Paul Lalli wrote:
> sunckell wrote:
> > [The same question he just posted]
>
> Please don't do that. Usenet is not instanteous. Not seeing your
> posted message immediately is not cause for posting the same message
> again.
>
> Paul Lalli
I didn't.. Something happened with Opera when I hit submit. It hung
for a few minutes. I ended up having to kill it from the command line
to get it to stop.
sunckell
------------------------------
Date: 28 Jul 2006 06:39:35 -0700
From: "sunckell" <sunckell@gmail.com>
Subject: Old output from regex.
Message-Id: <1154093975.678489.264180@m73g2000cwd.googlegroups.com>
Hello everyone,
I am getting some strange output from a regex. Wondering if anyone
can see what I am doing wrong. I am on a Solaris 8 server, running
perl 5.8
sub process_measurements{
my $cmd = "/usr/ucb/ps -auwwx";
my @trbl_pids;
open PS, "$cmd |" or die "Cannot open $cmd:$!\n";
while(<PS>){
next if /^USER/;
/^
(\w+) # user of process -- 1
\s+
(\d+) # pid of process -- 2
\s+
(\w+\.\w) # cpu percentage of process -- 3
\s+
(\w+\.\w) # memory percentage -- 4
\s+
(\w+) # virtual memory size -- 5
\s+
(\w+) # resident size of process -- 6
\s+
(\?|\w+\/\w+) # associated tty -- 7
\s+
(\w) # state of process -- 8
\s+
(.*) # start, time, and command -- 9
$/x or do
{
# this occurs when %MEM SZ ans RSS are wider than
# the column width and runs together. Which means
# they are higher usage processes. Will account
# for these separately.
warn "WARNING: line not in processable format:
$_\n";
my $user = $1;
my $pid = $2;
my $cpu = $3;
print "$pid $cpu $user\n";
push(@trbl_pids, $pid);
next;
}
}
close (PS);
print "TROUBLE: @trbl_pids\n";
}
Basically all I am doing is reading a ps output. When I print $user
and $pid I only get the first letter\digit of the field.
For example if root owns a process, I only get the letter r when I
print $user, where I should get root.
Anyone see my mistake, or am I over looking something in reading the
output?
Thanks,
sunckell
------------------------------
Date: 28 Jul 2006 06:46:44 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Old output from regex.
Message-Id: <1154094404.078073.73540@i42g2000cwa.googlegroups.com>
sunckell wrote:
> I am getting some strange output from a regex. Wondering if anyone
> can see what I am doing wrong. I am on a Solaris 8 server, running
> perl 5.8
>
> sub process_measurements{
> my $cmd = "/usr/ucb/ps -auwwx";
> my @trbl_pids;
>
> open PS, "$cmd |" or die "Cannot open $cmd:$!\n";
> while(<PS>){
> next if /^USER/;
>
> /^
> (\w+) # user of process -- 1
> \s+
> (\d+) # pid of process -- 2
> \s+
> (\w+\.\w) # cpu percentage of process -- 3
> \s+
> (\w+\.\w) # memory percentage -- 4
> \s+
> (\w+) # virtual memory size -- 5
> \s+
> (\w+) # resident size of process -- 6
> \s+
> (\?|\w+\/\w+) # associated tty -- 7
> \s+
> (\w) # state of process -- 8
> \s+
> (.*) # start, time, and command -- 9
>
> $/x or do
"or" means that the following block will be executed if the above
pattern did NOT match.
> {
> # this occurs when %MEM SZ ans RSS are wider than
> # the column width and runs together. Which means
> # they are higher usage processes. Will account
> # for these separately.
> warn "WARNING: line not in processable format:
> $_\n";
> my $user = $1;
> my $pid = $2;
> my $cpu = $3;
If the above pattern didn't match (which is the only way to be in this
block), $1, $2, and $3 were not set. The values of these variables
whatever they were after the last *successful* pattern match.
> print "$pid $cpu $user\n";
> push(@trbl_pids, $pid);
> next;
> }
> }
> close (PS);
> print "TROUBLE: @trbl_pids\n";
> }
>
>
> Basically all I am doing is reading a ps output.
Have you considered using an already-built solution, like
Proc::ProcessTable ?
> When I print $user
> and $pid I only get the first letter\digit of the field.
>
> For example if root owns a process, I only get the letter r when I
> print $user, where I should get root.
>
>
> Anyone see my mistake, or am I over looking something in reading the
> output?
You have a logic error. You can't say "if this pattern doesn't match,
print out the values of the successfully matched pattern".
Paul Lalli
------------------------------
Date: 28 Jul 2006 07:27:17 -0700
From: "sunckell" <sunckell@gmail.com>
Subject: Re: Old output from regex.
Message-Id: <1154096836.978966.70120@i3g2000cwc.googlegroups.com>
Thanks Paul,
Redefining the regex in the failed loop did it. As for
Proc::ProcessTable, not every server on our network has perl 5.6.0 and
above. I am trying to write it so I can drop it on any server if need
be.
thanks again
------------------------------
Date: Fri, 28 Jul 2006 15:55:53 +0200
From: Holger <spam.trap.never.read@mailinator.com>
Subject: Re: Questions about (non-blocking) sockets
Message-Id: <44ca0f6a.5191257@news.arcor.de>
On 27 Jul 2006 16:37:53 GMT, xhoster@gmail.com wrote:
> There are two risks for deadlock here if your print to the socket in a
> blocking (and even more so blocking and buffered) way, but they depend on
> the unknown behavior of the other end (which I'll call the server). Since
> the server seems to have two streams of output, one in reponse to the
> client and one autonomous stream, how does it interweave them and are they
> blocking or not?
I don't know details about the interweaving; I can only guess from the
data. There seem to be certain fixed data sequences, but in general I
suppose this depends on the events the server receives, e.g. from
other users. My guess is that it handles everything asynchronously,
because answers don't relate to a particular command. It may even be
the case that due to server load it doesn't answer. One thing which is
assured of course, is that messages are fully sent before the next
one.
> If the server prints the autonomous stream in a blocking
> way, then it is possible that a big slug of autonomous data after your code
> passes the recv and/or timeout but before your code finishes "do stuff;
> send data". Then you might block waiting for server to read the data you
> are trying to send, and thus you will not doing any "recv"ing; while the
> server is blocked waiting for you to recv the autonomous data, refusing to
> read more commands from you until you read form it.
I think the server doesn't block on read and would keep sending
anyway. Hmm, how would I actually test this? Syswrite something
without a record separator and then try to read?
[scenarios snipped]
> So in short, if you don't know how the server handles its data, you might
> want to consider making the "send data" part in a nonblocking way using
> select and syswrite rather than print. Of course, it depends on your
> paranoia/laziness trade off.
Thanks, points taken. I'll have a closer look at that.
Regards,
Holger
------------------------------
Date: 28 Jul 2006 15:57:58 GMT
From: xhoster@gmail.com
Subject: Re: Questions about (non-blocking) sockets
Message-Id: <20060728120500.337$gy@newsreader.com>
Holger <spam.trap.never.read@mailinator.com> wrote:
> On 27 Jul 2006 16:37:53 GMT, xhoster@gmail.com wrote:
>
> > If the server prints the autonomous stream in a blocking
> > way, then it is possible that a big slug of autonomous data after your
> > code passes the recv and/or timeout but before your code finishes "do
> > stuff; send data". Then you might block waiting for server to read the
> > data you are trying to send, and thus you will not doing any "recv"ing;
> > while the server is blocked waiting for you to recv the autonomous
> > data, refusing to read more commands from you until you read form it.
>
> I think the server doesn't block on read and would keep sending
> anyway.
I don't think that that is what I was trying to describe. The server is
not blocking on read, it is blocking on write (waiting for the client to
read). In other words, it is trying to keep sending, but the client won't
read what it is writing and the buffer is full, so its attempt at sending
blocks.
> Hmm, how would I actually test this? Syswrite something
> without a record separator and then try to read?
Don't try to read at all, just keep writing. syswrite or print, doesn't
matter but print is easier, and you may as well use a record separator
(otherwise you would be testing something different). If the server uses
blocking writes to you, then eventually the server will block on its write
to you, and hence stop reading what you write to it, and then you will
block on writing to it, resulting in a deadlock.
while (1) {
print $SOCKET $one_datachunk;
warn "done with one more chunk ",$count++;
};
If the program freezes for a long time (stops printing the warnings) then
it probably deadlocked.
Of course, if you do this and the server doesn't use blocking writes but
rather stores up all the stuff it wants to write but can't, then its memory
usage will grow without limit. So if it doesn't block (kepts emitting the
warnings), then either don't let this run for too long, or monitor the
server processes size.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Fri, 28 Jul 2006 15:05:07 +0200
From: Wolfram Humann <w.n.humann@agilent.com>
Subject: Strange characters using Term::Readline on Win32
Message-Id: <1154091485.664297@newsreg.cos.agilent.com>
Hope this is not too much a DOS/Windows question to be answered here...
I'm getting strange characters (escape sequences???) at the prompt and when typing characters using
Term::ReadLine. As an example I type 'ABCD' followed by the return key at the prompt generated by
this line:
perl -M"Term::ReadLine" -e"Term::ReadLine->new('')->readline('PROMPT')"
and what I get is this:
←[4;mPROMPT←[1mA←[0m←[1mB←[0m←[1mC←[0m←[1mD←[0m
I've already tried to change code-pages, but that doesn't help. I'm using Windows XP and ActiveState
perl v5.8.7 build 815.
Thanks for any help,
Wolfram
------------------------------
Date: Fri, 28 Jul 2006 13:15:33 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Strange characters using Term::Readline on Win32
Message-Id: <Xns980E5E486F4B7asu1cornelledu@127.0.0.1>
Wolfram Humann <w.n.humann@agilent.com> wrote in
news:1154091485.664297@newsreg.cos.agilent.com:
> Hope this is not too much a DOS/Windows question to be answered
> here...
>
> I'm getting strange characters (escape sequences???) at the prompt and
> when typing characters using Term::ReadLine. As an example I type
> 'ABCD' followed by the return key at the prompt generated by this
> line:
>
> perl -M"Term::ReadLine"
> -e"Term::ReadLine->new('')->readline('PROMPT')"
>
> and what I get is this:
>
> ←[4;mPROMPT←[1mA←[0m←[1mB←[0m←[1mC←[0m←[1mD←[0m
>
> I've already tried to change code-pages, but that doesn't help. I'm
> using Windows XP and ActiveState perl v5.8.7 build 815.
Sorry, can't replicate:
C:\Home\asu1> perl -MTerm::ReadLine -e"Term::ReadLine->new('')->readline
('PROMPT:> ')"
PROMPT:>
C:\Home\asu1> perl -v
This is perl, v5.8.8 built for MSWin32-x86-multi-thread
(with 25 registered patches, see perl -V for more detail)
Copyright 1987-2006, Larry Wall
Binary build 817 [257965] provided by ActiveState
http://www.ActiveState.com
C:\Home\asu1> perl -MTerm::ReadLine -e "print $Term::ReadLine::VERSION"
1.02
Sinan
--
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: 28 Jul 2006 08:19:06 -0700
From: "Thomas J." <jue@monster-berlin.de>
Subject: Re: Strange characters using Term::Readline on Win32
Message-Id: <1154099946.173716.96920@m79g2000cwm.googlegroups.com>
V29sZnJhbSBIdW1hbm4gc2NocmllYjoKPgo+IOKGkFs0O21QUk9NUFTihpBbMW1B4oaQWzBt4oaQ
WzFtQuKGkFswbeKGkFsxbUPihpBbMG3ihpBbMW1E4oaQWzBtCj4KCgpJIGNhbnQgcmVwbGljYXRl
IHRoYXQuLi4KClRoaXMgIkVTQy1zZXF1ZW5jZXMiIGxvb2tzIGxpa2Ugc2V0dGluZyBhdHRyaWJ1
dHMgKGxpa2UgdGhhdCBpbgpBTlNJQ29sb3IucG0pCgppcyBUZXJtOjpSZWFkTGluZSB1cC10by1k
YXRlPyAKClRob21hcwo=
------------------------------
Date: 28 Jul 2006 06:07:32 -0700
From: "lnatz" <nmrabinovich@gmail.com>
Subject: Sybase connection error
Message-Id: <1154092052.272084.15850@p79g2000cwp.googlegroups.com>
Hi I am having a problem with this line of code:
$DBH =
DBI->connect("dbi:Sybase:server=$dbserver", $dbuser, $dbpassword)
|| die "$DBI::errstr";
$DBH->do("use $database");
I am getting this error when executing:
DBI connect('server=NYT_LIBRAONLINE','natrabi
',...) failed: Server message number=4002 severity=14 state=1 line=0
server=NYTINV3T002 text=Login failed.
OpenClient message: LAYER = (4) ORIGIN = (1) SEVERITY = (4) NUMBER =
(44)
Server NYT_LIBRAONLINE, database
Message String: ct_connect(): protocol specific layer: external error:
The attempt to connect to the server failed.
at ./purge.pl line 45
Server message number=4002 severity=14 state=1 line=0
server=NYTINV3T002 text=Login failed.
OpenClient message: LAYER = (4) ORIGIN = (1) SEVERITY = (4) NUMBER =
(44)
Server NYT_LIBRAONLINE, database
Message String: ct_connect(): protocol specific layer: external error:
The attempt to connect to the server failed.
Basically I am trying to connect to Sybase and I can't figure out what
I am missing.
------------------------------
Date: 28 Jul 2006 10:12:17 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Text descriptions of signal codes?
Message-Id: <4iu681F5g7tqU3@news.dfncis.de>
<allenjo5@mail.northgrum.com> wrote in comp.lang.perl.misc:
> Is there as easy a way to get the textual description of a process
> signal code in perl as there is to get the textual description of a
> system call error code? For instance, for an errno of 24, just set $!
> to 24 and use it as a string:
>
> $ perl -le '$!=24; print $!'
> The process file table is full.
>
> Is there something equivalent for getting the text meaning of signal
> code 24 (SIGXCPU) without having to parse signal.h? Yeah I can do
> that readily enough, but was expecting perl to provide an easier
> method. So far, I haven't found the trick.
The Config module has the table you want. Adapted from "perldoc
perlipc":
use Config;
defined $Config{sig_name} || die "No sigs?";
my ( @signame, %signo);
my $i = 0;
foreach my $name ( split(' ', $Config{sig_name}) ) {
$signo{$name} = $i;
$signame[$i] = $name;
$i++;
}
Anno
------------------------------
Date: 28 Jul 2006 07:16:11 -0700
From: "morrison" <contact.morrison@gmail.com>
Subject: Re: The "proper name" for the series: foo, bar, etc
Message-Id: <1154096171.098153.11220@i3g2000cwc.googlegroups.com>
usenet@DavidFilmer.com wrote:
> I can't remember the term he used (and I'm not even sure I heard it
> correctly). Does someone know the name of this series? I'm curious...
http://search.cpan.org/dist/Acme-MetaSyntactic :-)
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 9534
***************************************