Re: process output pipe autoflush

2000-12-05 Thread $Bill Luebkert

"$Bill Luebkert" wrote:
> 
> Mark Zvolanek wrote:
> >
> > Hi Carl,
> > I am sorry I don't understand.
> >
> > I was talking about $| variable and not $!.
> >
> > I am trying to figure out why my perl code
> > is buffering the (STDOUT) output of the executable
> > even though I have set the variable $| to 1.
> > Whereas when I execute the executable at
> > the command prompt its output is not buffered.
> >
> > You also said:  The PIPE handle is an input handle.
> > Why is it then my perl code below produces output
> > as passed to it by the executable.
> > ...
> > while (){
> > print;
> > }
> > ...
> 
> A new little test shows some insight.  Maybe buffering isn't used when
> writing to the console (vs a file/pipe):
> 
> Driver:
> 



> # this should print 1 line per second

Whoops, this last one should wait 10 seconds and then print all 10 lines
if buffering is on, but doesn't when going direct to console.

-- 
  ,-/-  __  _  _ $Bill Luebkert   ICQ=14439852
 (_/   /  )// //   DBE Collectibles   http://www.wgn.net/~dbe/
  / ) /--<  o // //  Mailto:[EMAIL PROTECTED]   http://dbecoll.webjump.com/
-/-' /___/_<_http://www.freeyellow.com/members/dbecoll/
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: process output pipe autoflush

2000-12-05 Thread $Bill Luebkert

Mark Zvolanek wrote:
> 
> Hi Carl,
> I am sorry I don't understand.
> 
> I was talking about $| variable and not $!.
> 
> I am trying to figure out why my perl code
> is buffering the (STDOUT) output of the executable
> even though I have set the variable $| to 1.
> Whereas when I execute the executable at
> the command prompt its output is not buffered.
> 
> You also said:  The PIPE handle is an input handle.
> Why is it then my perl code below produces output
> as passed to it by the executable.
> ...
> while (){
> print;
> }
> ...

A new little test shows some insight.  Maybe buffering isn't used when 
writing to the console (vs a file/pipe):

Driver:

use strict;

$| = 1; # buffering off

# ARGV[0] = $|, ARGV[1] = sleep, ARGV[2] = count

# this should wait 10 seconds and then print all 10 lines

open PIPE, "c:\\perl\\bin\\perl pipe.pl 0 1 10 |" or 
  die "Error starting pipe: $!\n";
while () {
print;
}
close PIPE;

# this should print 1 line per second

open PIPE, "c:\\perl\\bin\\perl pipe.pl 1 1 10 |" or 
  die "Error starting pipe: $!\n";
while () {
print;
}
close PIPE;

$| = 0; # buffering on

# this should wait 10 seconds and then print all 10 lines

open PIPE, "c:\\perl\\bin\\perl pipe.pl 0 1 10 |" or 
  die "Error starting pipe: $!\n";
while () {
print;
}
close PIPE;

# this should print 1 line per second

open PIPE, "c:\\perl\\bin\\perl pipe.pl 1 1 10 |" or 
  die "Error starting pipe: $!\n";
while () {
print;
}
close PIPE;

__END__


Test exe (pipe.pl):

use strict;

print STDERR "buffer=$ARGV[0]; " if defined $ARGV[0];
print STDERR "sleep=$ARGV[1]; " if defined $ARGV[1];
print STDERR "count=$ARGV[2]\n" if defined $ARGV[2];

$| = $ARGV[0] if defined $ARGV[0];

my $count = 1000;
$count = $ARGV[2] if defined $ARGV[2];
for (my $ii = 0; $ii < $count; $ii++) {
print 
"$ii: Testing 1234567890 The quick brown fox jumped over the lazy dog's back\n";
sleep $ARGV[1] if defined $ARGV[1] and $ARGV[1] > 0;
}
__END__


If you pipe the output to less, you get different results than if 
you let it go to console. 1-4 are the four exe executions.

1) wait 10; print 10
2) wait 1; print 1 - ten times
3) wait 10; print 10
4a) wait 10; print 10 (when going to pipe)
4b) wait 1; print 1 - ten times (when going to console)

-- 
  ,-/-  __  _  _ $Bill Luebkert   ICQ=14439852
 (_/   /  )// //   DBE Collectibles   http://www.wgn.net/~dbe/
  / ) /--<  o // //  Mailto:[EMAIL PROTECTED]   http://dbecoll.webjump.com/
-/-' /___/_<_http://www.freeyellow.com/members/dbecoll/
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: reading hash from file did not produce expected results

2000-12-05 Thread Rogers, John

Well I am a legend in my own mind.

> -Original Message-
> From: Jon Bjornstad [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, December 06, 2000 12:33 PM
> To:   Rogers, John; '[EMAIL PROTECTED]'
> Subject:  Re: reading hash from file did not produce expected results
> 
> > is this Normal ?
> > I want to Know why the values also have the keys, and what Ive done
> wrong.
> > 
> > not yet a Perl legend.
> > John Rogers
> > System Engineer
> > OCE Australia
> 
> I love your sign-off message... not yet a Perl legend.
> 
> it takes time to learn some of the
> weird ways of perl.   keep at it.
> it can be a great deal of fun!
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
> 
> 
## 
Disclaimer 

If this e-mail has been sent to you in error, please notify 
Océ-Australia Limited immediately and delete this e-mail from 
your system. 

Any views expressed in this e-mail are those of the individual 
sender and may not necessarily reflect the views of 
Océ-Australia Limited. 
##
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: reading hash from file did not produce expected results

2000-12-05 Thread Rogers, John

Thankyou Tom and Jon,

Learning new things can be a trial(for me at least) and sometimes you can
look at things so much
you go "brain dead" with it, and not see the obvious.
Thanks again 
John
> -Original Message-
> From: Tom Heady [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, December 06, 2000 11:35 AM
> To:   Rogers, John; '[EMAIL PROTECTED]'
> Subject:  Re: reading hash from file did not produce expected results
> 
> 
> here's a walkthrough, starting at the second line of your text file
> 
> 
> >#-start
> >#!perl -w
> >$extnum='8114'; # at the moment.
> >open(ADDR, "addressbook.txt") or die "cant open $!\n";
> >while() {
> 
> the value of $_ = "8114,[EMAIL PROTECTED]\n"
> 
> > chomp;
> 
> the value of $_ = "8114,[EMAIL PROTECTED]"
> 
> > ($number)=(split(/\,/));
> 
> the value of $number = "8114"
> 
> > $ext{$number}=$_;
> 
> the value of $ext{8114} = "8114,[EMAIL PROTECTED]";
> 
> > }
> >
> >close (ADDR);
> 
> 
> i think what you want to do is this:
> while() {
>   chomp;
>   ($number, $email)=(split(/\,/));
>   $ext{$number}=$email;
> }
> 
> sometimes it helps when you print the things that you are working with
> when you are trying to debug
> a few print "$_\n"; and you would have found this by yourself.
> 
> ---tom
> 
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
> 
> 
## 
Disclaimer 

If this e-mail has been sent to you in error, please notify 
Océ-Australia Limited immediately and delete this e-mail from 
your system. 

Any views expressed in this e-mail are those of the individual 
sender and may not necessarily reflect the views of 
Océ-Australia Limited. 
##
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: FW: Win32-SerialPort Problem

2000-12-05 Thread IMCEANOTES-Ian+20Stewart_Great+20Lakes_AirTouch+40AIRTOUCH+40AIRTOUCH+5FCONNECT




From:   "Tuan Tran <[EMAIL PROTECTED]>"   -Original Message-
> From: Tuan Tran <[EMAIL PROTECTED]>  
> Sent: Friday, December 01, 2000 3:25 PM
> To:   '[EMAIL PROTECTED]'
> Subject:  Win32-SerialPort Problem
> 
> -- Hi,
> I download Perl 5.6 supported Window NT to my computer. And I copy
a
> script program from mail list to test COM1.
> After I execute it, a "Perl.exe- unable to locate DLL. PerlCRT.dll
could
> not be found in the specified path" message is displayed on
window. Then,
> I lick O.K., MSDOS prompt displays 10 more lines messages attached
to this
> email. Does Perl ver. 5.6 support Win32 serial port ?. Can You
show me how
> to make it work and open COM port1 by Perl ?

I ran into a similiar problem with DBI when upgrading from Build 522
to Build 620.  After uninstalling, and then re-installing DBI and
DBD-Oracle, the problem went away.

I'm wondering if this is perhaps a case of the Perl5.005 DLL being
resident in memory, preventing the Perl 5.6 library from loading and making
it look like the library doesn;t support Perl 5.6?  Just a theory...


HTH,
Ian

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: reading hash from file did not produce expected results

2000-12-05 Thread Tom Heady


here's a walkthrough, starting at the second line of your text file


>#-start
>#!perl -w
>$extnum='8114'; # at the moment.
>open(ADDR, "addressbook.txt") or die "cant open $!\n";
>while() {

the value of $_ = "8114,[EMAIL PROTECTED]\n"

>   chomp;

the value of $_ = "8114,[EMAIL PROTECTED]"

>   ($number)=(split(/\,/));

the value of $number = "8114"

>   $ext{$number}=$_;

the value of $ext{8114} = "8114,[EMAIL PROTECTED]";

>   }
>
>close (ADDR);


i think what you want to do is this:
while() {
chomp;
($number, $email)=(split(/\,/));
$ext{$number}=$email;
}

sometimes it helps when you print the things that you are working with when you are 
trying to debug
a few print "$_\n"; and you would have found this by yourself.

---tom

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



reading hash from file did not produce expected results

2000-12-05 Thread Rogers, John

Howdy all,

I have simple comma delimited file that looks like this,

ext no,email
8114,[EMAIL PROTECTED]
5678,[EMAIL PROTECTED]
7890,[EMAIL PROTECTED]

now I want to read this file into a hash, so I wrote, (with the aid of much
reading)
#-start
#!perl -w
$extnum='8114'; # at the moment.
open(ADDR, "addressbook.txt") or die "cant open $!\n";
while() {
chomp;
($number)=(split(/\,/));
$ext{$number}=$_;
}

close (ADDR);
#now if i
print "$ext{$extnum}\n";
#end

The print produces,
G:\s2e>perl hashtry.pl
8114,[EMAIL PROTECTED]   

I was expecting just [EMAIL PROTECTED]   

if I look at the Hash with perl -d 
  DB<1> x %ext
0  5678
1  '5678,[EMAIL PROTECTED]'
2  'ext no'
3  'ext no,email'
4  7890
5  '7890,[EMAIL PROTECTED]'
6  8114
7  '8114,[EMAIL PROTECTED]'

Now I can "clean" it up by adding, $ext{$number}=~(s/$extnum\, //); to the
while loop.
is this Normal ?
I want to Know why the values also have the keys, and what Ive done wrong.

not yet a Perl legend.
John Rogers
System Engineer
OCE Australia
 
 Todays Quote, 
"We want a few mad people now. See where the sane ones have landed us!"
George Bernard Shaw (1856-1950)





## 
Disclaimer 

If this e-mail has been sent to you in error, please notify 
Océ-Australia Limited immediately and delete this e-mail from 
your system. 

Any views expressed in this e-mail are those of the individual 
sender and may not necessarily reflect the views of 
Océ-Australia Limited. 
##
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



FW: Win32-SerialPort Problem

2000-12-05 Thread Tuan Tran <[EMAIL PROTECTED]>



>  -Original Message-
> From: Tuan Tran <[EMAIL PROTECTED]>  
> Sent: Friday, December 01, 2000 3:25 PM
> To:   '[EMAIL PROTECTED]'
> Subject:  Win32-SerialPort Problem
> 
> -- Hi,
> I download Perl 5.6 supported Window NT to my computer. And I copy a
> script program from mail list to test COM1.
> After I execute it, a "Perl.exe- unable to locate DLL. PerlCRT.dll could
> not be found in the specified path" message is displayed on window. Then,
> I lick O.K., MSDOS prompt displays 10 more lines messages attached to this
> email. Does Perl ver. 5.6 support Win32 serial port ?. Can You show me how
> to make it work and open COM port1 by Perl ?
> 
> Regards,
> Tuan
> 
> 
>  <> 



-Script File--
use Win32::SerialPort;
$ComPort = "COM1"
$ob = Win32::SerialPort->new ($ComPort);
while(1)
{
$cmd=;
chomp($cmd);
$ob->write("$cmd");
$ob->read;
}
--

C:\>perl a:\mod.pl
Can't load 'D:/perl/site/lib/auto/Win32/API/API.dll' for module Win32::API: load
_file:The specified module could not be found at D:/perl/lib/DynaLoader.pm line
200.
 at D:/perl/lib/Win32API/CommPort.pm line 5
Compilation failed in require at D:/perl/lib/Win32API/CommPort.pm line 5.
BEGIN failed--compilation aborted at D:/perl/lib/Win32API/CommPort.pm line 5.
Compilation failed in require at D:/perl/lib/Win32/SerialPort.pm line 4.
BEGIN failed--compilation aborted at D:/perl/lib/Win32/SerialPort.pm line 4.
Compilation failed in require at a:\mod.pl line 1.
BEGIN failed--compilation aborted at a:\mod.pl line 1.



Re: how to check if a dir exists...

2000-12-05 Thread Carl Jolley

On Sun, 3 Dec 2000, Fabio Quintao wrote:

> hi everybody
> 
>  can someone help me? i want to check if some directory exist in my
> computer..
> i'm not sure if i should use seekdir or whatever and how to use.
>   i hope someone can help me how.
>thanks in advance

Why don't you just use the -d 'file test' function?

 [EMAIL PROTECTED] 
 All opinions are my own and not necessarily those of my employer 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: New service in NT

2000-12-05 Thread Michael Fountain

I use a program called 'schedule assistant! for NT'

You can use it to run scripts, batch files, .exe files, whatever, whenever 
you want.

I don't want to pass it to everyone on this board (it is a 1.1MB file), but 
if you email me direct, I'll send it to you - it is a freeware program.  I 
would send a link, but I can't seem to find it on the web anymore.


>
>Sorry if this is a little off topic but I'm kind of in a jam.
>
>I've got a bunch of perl scripts I'm using to remotely administer a grip
>of NT Server machines.  After a reboot (brought on by a perl script) I
>need my cron job (perl script) to start up automatically without having
>to auto-login and put the cron script in the start-up folder of that
>user.  I'd *really* like to create a new NT service for this cron script
>but I don't know how to do that.  And would it have to be an .exe rather
>than a .pl if I can even do this?
>
>THANKS A LOT in advance once again,
>Jon
>
>___
>Perl-Win32-Users mailing list
>[EMAIL PROTECTED]
>http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

_
Get more from the Web.  FREE MSN Explorer download : http://explorer.msn.com

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Convert MM/DD/YYYY to day of Week

2000-12-05 Thread bb

I have a date in the format of "mm/dd/" I would like to convert
it to day of week (Sun,Mon,Tue,Wed,Thu,Fri,Sat).  
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: hash with an array as value

2000-12-05 Thread erskine, michael

A hash value is always a scalar and provides scalar context (hence the array
size appearing in your hash values). What you want to do is store references
to the arrays (references are stored in scalars and can therefore be used as
hash values). See M-J. Dominus's excellent Perl Journal article, "Understand
References Today". This will give you all the answers you need.

http://perl.plover.com/FAQs/references.html


Michael Erskine (MSEmtd)
mailto:[EMAIL PROTECTED]

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Dealing with a space in a directory name

2000-12-05 Thread Paul Popour


- Original Message -
From: "Sweet Gordon" <[EMAIL PROTECTED]>
To: "'perl-win32-userslistservActiveStatecom'"
<[EMAIL PROTECTED]>
Sent: Monday, December 04, 2000 5:32 PM
Subject: Dealing with a space in a directory name


> I'm using the globbing function to return a list of filenames from the
> specified directory (e.g. @filelist =  and it's working
great
> unless the directory has a space in it's name (e.g. ).
> I've played around with adding quotes but so far, nothing has worked. Any
> help would be appreciated.

Go to a command prompt and type a dir command of the parent directory with a
/x switch, ie.,

 dir c:\ /x

This will give you the 8.3 directory names which is what glob needs.  You
can get that progromatically using the GetShortPathName function.  Not
trying to worm down any further than the first level you could do something
like -

==
$dir = "C:\\";
@root = glob("$dir\\*");
foreach $rootdir (@root)
 {
 if (grep(/ /, $rootdir)){$rootdir = Win32::GetShortPathName($rootdir);}
 @filenames = glob("$rootdir\\*");
 foreach $filename (@filenames){print "$filename\n";}
 }

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Help -- PostMessage() or SendMessage()

2000-12-05 Thread Aldo Calpini

A. C. Yardley wrote:
> Hello,
>
> I need a bit of help here:  I'm try to use the Win32::API
> module to call WinAPI's PostMessage() or SendMessage()
> functions.  Please see below.
>
> [...]
>
> So, would a call to PostMessage() look like
>
> my $PostMessage = new Win32::API "user32", "PostMessage",
> [qw(N N P P)], 'N';
>
> or
>
> my $PostMessage = new Win32::API "user32", "PostMessage",
> [qw(N N N N)], 'N';

in your case, you should use qw(N N P P). it depends on the
nature of the data you pass to the function.

> Then, how do I properly pack the COPYDATASTRUCT and then
> get a pointer to the packed structure in order to pass it
> as a parameter in the PostMessage() call?  Does the below
> bit of code appear correct?  (Because it doesn't work.)
>
> my $wparm = pack("I", NULL);
> my $lpCopydatastruct = pack("III", WM_USERKILL, 4, NULL);
> my $lparm = pack("P", $lpCopydatastruct);
> my $lresult = $PostMessage->Call($hwnd, WM_COPYDATA, $wparm,
> $lparm);

some hints:

first of all, from the WM_COPYDATA documentation:
  "To send this message, call the SendMessage function with
  the following parameters (do not call the PostMessage
  function)."

so you should s/Post/Send/g anyway.

second, packing the COPYDATASTRUCT should probably look
like this:

  my $dwData = pack("L", WM_USERKILL);
  my $lpCopydatastruct = pack("pLp", $dwData, 0, NULL);

if you pass 4 in cbData, the application expects 4 bytes
of information in lpData, that you're not going to give.

also note that a DWORD is a long, not an integer, so you
need to pack("L"). furthermore, dwData is a ULONG_PTR,
not a DWORD, so you need to pack a pointer here.

third, if you declared $SendMessage with qw(N N P P), you
don't need to pack pointers, Win32::API will do this for you:

  my $lresult = $SendMessage->Call($hwnd, WM_COPYDATA,
  $wparm, $lpCopydatastruct);

hope this helps...


cheers,
Aldo

__END__
$_=q,just perl,,s, , another ,,s,$, hacker,,print;


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: process output pipe autoflush

2000-12-05 Thread erskine, michael

> -Original Message-
> From: Mark Zvolanek [mailto:[EMAIL PROTECTED]]
> Sent: 05 December 2000 03:48
> To: '[EMAIL PROTECTED]'
> Cc: Mark Zvolanek
> Subject: process output pipe autoflush

> I have a problem with autoflush. Platform is Windows NT 4 / sp6.

Mark, (in fact everyone!)

You should read M-J. Dominus's excellent Perl Journal article, "Suffering
from Buffering?". This will give you all the answers you need.

http://perl.plover.com/FAQs/Buffering.html

In fact everyone who hasn't already should read *ALL* of M-J's articles - it
almost makes newsgroup support obsolete (except for all the Win32 caveats of
course!)...

http://perl.plover.com/


Michael Erskine (MSEmtd)
mailto:[EMAIL PROTECTED]

 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users