Re: send output to a parallel port?

2005-07-20 Thread Sisyphus

- Original Message - 
From: robert [EMAIL PROTECTED]
To: perl-win32-users@listserv.ActiveState.com
Sent: Wednesday, July 20, 2005 1:27 PM
Subject: send output to a parallel port?


 Hey all

 we have some devices at work that are controlled by sending signals via
the
 computer's parallel port.  (because all the serial ports are being used
 elsewhere)

 the parallel port (LPT) has the address 0x378.  to do this in C, its quite
 simple:

 void parallel_device (int state)
 {
 outp (0x378,state);
 return;
}

Afaik a function declared as void would not return.

Anyway, if it's that simple to do in C then it's also very simple to achieve
in perl, using Inline::C. Here is the script (untested):

--start test.pl

use warnings;
use strict;

use Inline C = Config =
LIBS = '', # specify additional libs - eg '-lmylib'
BUILD_NOISY = 1; # verbose output during compilation

use Inline C = 'EOC';

//#include whatever.h // List any includes here

void inline_parallel_device(int state) {
outp(0x378, state);
}

EOC;

# perl code starts here:

my $state = 12345; # or whatever you want

# inline_parallel_device() does exactly the same as parallel_device().
inline_parallel_device($state);

# Then do whatever it is you want to do.

__END__

--- end test.pl ---

But you'll need a compiler for that to work - preferably MSVC++ 6.0 if
you're running ActiveState perl, though the free command line version of
MSVC++ 7.1 (.NET 2003  or whatever it is) that's available from
Microsoft will probably serve just as well.

With ActiveState perl, a third alternative is to install nmake or dmake, and
the MinGW (gcc) compiler, along with ExtUtils::FakeConfig. (All of those are
freely available.)

Cheers,
Rob

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: send output to a parallel port?

2005-07-20 Thread Ken Cornetet
Writing to an IO port from a user program isn't allowed under NT/2k/XP.

To do this you need some sort of driver.

Check out http://www.winfordeng.com/products/portio32/#samples

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Sisyphus
Sent: Wednesday, July 20, 2005 3:55 AM
To: robert; perl-win32-users@listserv.ActiveState.com
Subject: Re: send output to a parallel port?


- Original Message -
From: robert [EMAIL PROTECTED]
To: perl-win32-users@listserv.ActiveState.com
Sent: Wednesday, July 20, 2005 1:27 PM
Subject: send output to a parallel port?


 Hey all

 we have some devices at work that are controlled by sending signals
via
the
 computer's parallel port.  (because all the serial ports are being
used
 elsewhere)

 the parallel port (LPT) has the address 0x378.  to do this in C, its
quite
 simple:

 void parallel_device (int state)
 {
 outp (0x378,state);
 return;
}

Afaik a function declared as void would not return.

Anyway, if it's that simple to do in C then it's also very simple to
achieve
in perl, using Inline::C. Here is the script (untested):

--start test.pl

use warnings;
use strict;

use Inline C = Config =
LIBS = '', # specify additional libs - eg '-lmylib'
BUILD_NOISY = 1; # verbose output during compilation

use Inline C = 'EOC';

//#include whatever.h // List any includes here

void inline_parallel_device(int state) {
outp(0x378, state);
}

EOC;

# perl code starts here:

my $state = 12345; # or whatever you want

# inline_parallel_device() does exactly the same as parallel_device().
inline_parallel_device($state);

# Then do whatever it is you want to do.

__END__

--- end test.pl ---

But you'll need a compiler for that to work - preferably MSVC++ 6.0 if
you're running ActiveState perl, though the free command line version of
MSVC++ 7.1 (.NET 2003  or whatever it is) that's available from
Microsoft will probably serve just as well.

With ActiveState perl, a third alternative is to install nmake or dmake,
and
the MinGW (gcc) compiler, along with ExtUtils::FakeConfig. (All of those
are
freely available.)

Cheers,
Rob

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: send output to a parallel port?

2005-07-20 Thread robert


 -Original Message-
 From: Sisyphus  

 Afaik a function declared as void would not return.

it won't return a value, but it still has to go back to the caller.
 
 Anyway, if it's that simple to do in C then it's also very 
 simple to achieve in perl, using Inline::C. 

thats interesting, and would be useful for large C programs

but i've already compiled the C into a standalone executable, and
can call the .EXE as a system call from perl.

i mean yeah, it works, but what i want to do is avoid C altogether.

for aesthetic purposes.  

its basically one line of C code:  outp(IOPort,byte), and
certainly
not worth the module overhead

can't perl do this?

Rob



 

 
 But you'll need a compiler for that to work - preferably 
 MSVC++ 6.0 if you're running ActiveState perl, though the 
 free command line version of
 MSVC++ 7.1 (.NET 2003  or whatever it is) that's available from
 Microsoft will probably serve just as well.
 
 With ActiveState perl, a third alternative is to install 
 nmake or dmake, and the MinGW (gcc) compiler, along with 
 ExtUtils::FakeConfig. (All of those are freely available.)
 
 Cheers,
 Rob
 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


help with getting file stats

2005-07-20 Thread lorid

I am trying to get the file stats
I found this code in ch8 of perl cookbook
( $dev, $ino, $mode, $nlink,
 $uid, $gid, $rdev, $size,
 $atime, $mtime, $ctime,
 $blksize, $blocks )   = stat($filename)

and read the man page for stat  and  perlfunc but cant  seem to get a 
simple program to get the file stats
after reading the man page for stat I thought my problem might be that I 
need to use fstat since the file may be open

but that doesnt seem to work either

any suggestions would be appreciated.
my simple test program:


#!/usr/local/bin/perl


use File::stat;



my $dir_ctr = 0;
my $file_ctr = 0;


my $dir = /home/lorid/wrccpics;

 print Opening $dir \n;

 opendir DH, $dir  or die Can't open the current dir $!\n;
 while($file = readdir(DH)){

   if(-d $dir/$file){  
 print \n Dir: $file \n;

 $dir_ctr++;
   }
   elsif(-e $dir/$file){  
 print \nFile: $file \n;  
( $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, 
$mtime, $ctime, $blksize, $blocks ) = stat($file);
 print \n $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, 
$atime,Mtime: $mtime,\n Ctime:$ctime,\n $blksize, $blocks\n;

 $file_ctr++;
   }

 }

print \n;
print number of directories: $dir_ctr;
print \n;
print number of files: $file_ctr;

print \n;
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: send output to a parallel port?

2005-07-20 Thread Thad Schultz
- Original Message - 
From: robert [EMAIL PROTECTED]
To: perl-win32-users@listserv.ActiveState.com
Sent: Wednesday, July 20, 2005 1:27 PM
Subject: send output to a parallel port?


 Hey all

 we have some devices at work that are controlled by sending signals via
the
 computer's parallel port.  (because all the serial ports are being used
 elsewhere)

 the parallel port (LPT) has the address 0x378.  to do this in C, its quite
 simple:

 void parallel_device (int state)
 {
 outp (0x378,state);
 return;
}

I think this question came up once already.  Go to 
http://www.logix4u.net/inpout32.htm and download inpout32.dll (link is clear 
down at the bottom of the page).  Here's the perl code I use to play around.  I 
never got around to doing anything useful with it.  Hope this helps.

---code---
use strict;
use warnings;
use Win32::API; #load API module to interface DLL's

my $GetPortVal = Win32::API-new('inpout32', 'Inp32', ['I'], 'I') or die 
Couldn't create Win32::API object: $! $^E;

my $SetPortVal=  Win32::API-new('inpout32', 'Out32', ['I','I'], 'I') or die 
Couldn't create Win32::API object: $! $^E;

my $input= $GetPortVal-Call(0x378)  255; #get and display current value of 
address 378 hex print $input\n;
print Original Port Value=$input\n\n;

my $return=$SetPortVal-Call(0x378,0x23); #set pins 2,3,7 (pins, not bits)
print Call return value=$return\n\n;

$input= $GetPortVal-Call(0x378)  255; #get and display updated value  of 
address 378 hex
print New Port Value=$input\n;

---code---

Thad Schultz
EDA Librarian / Sys Admin
Woodward Industrial Controls 
[EMAIL PROTECTED]
ph (970)498-3570
fax (970)498-3077
www.woodward.com





***
The information in this e-mail is confidential and intended solely for the 
individual or entity to whom it is addressed.  If you have received this e-mail 
in error, please notify the sender by return e-mail, delete this e-mail, and 
refrain from any disclosure or action based on the information.
***

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: help with getting file stats

2005-07-20 Thread Wagner, David --- Senior Programmer Analyst --- WGO
[EMAIL PROTECTED] wrote:
 I am trying to get the file stats
 I found this code in ch8 of perl cookbook
 ( $dev, $ino, $mode, $nlink,
   $uid, $gid, $rdev, $size,
   $atime, $mtime, $ctime,
   $blksize, $blocks )   = stat($filename)
 
 and read the man page for stat  and  perlfunc but cant  seem to get a
 simple program to get the file stats
 after reading the man page for stat I thought my problem might be
 that I need to use fstat since the file may be open
 but that doesnt seem to work either
 
 any suggestions would be appreciated.
 my simple test program:
 
 
 #!/usr/local/bin/perl
 
 
 use File::stat;
 
 
 
 my $dir_ctr = 0;
 my $file_ctr = 0;
 
 
 my $dir = /home/lorid/wrccpics;
 
   print Opening $dir \n;
 
   opendir DH, $dir  or die Can't open the current dir $!\n;
   while($file = readdir(DH)){
 
 if(-d $dir/$file){
   print \n Dir: $file \n;
   $dir_ctr++;
 }
 elsif(-e $dir/$file){
   print \nFile: $file \n;
  ( $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime,
 $mtime, $ctime, $blksize, $blocks ) = stat($file);
If you look at the -d and -e you will see that it is concatenating the 
dir and file. You are only giving it the file and it does not exist.  You will 
need to either use the same setup of $dir/$file or you could do a chdir against 
the $dir and then the $file should work.

Wags ;)
   print \n $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
 $atime,Mtime: $mtime,\n Ctime:$ctime,\n $blksize, $blocks\n;
   $file_ctr++;
 }
 
   }
 
 print \n;
 print number of directories: $dir_ctr;
 print \n;
 print number of files: $file_ctr;
 
 print \n;
 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



***
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
***


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: help with getting file stats

2005-07-20 Thread Darrell Gammill
Have you tried stat ($dir/$file)?  If you just stat ($file), $file
would have to be the full path or a file in the current directory.  Do
you have a sample output you could share?

-Dgg

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
lorid
Sent: Wednesday, July 20, 2005 3:34 PM
To: perl-win32-users
Subject: help with getting file stats


I am trying to get the file stats
I found this code in ch8 of perl cookbook
( $dev, $ino, $mode, $nlink,
  $uid, $gid, $rdev, $size,
  $atime, $mtime, $ctime,
  $blksize, $blocks )   = stat($filename)

and read the man page for stat  and  perlfunc but cant  seem to get a 
simple program to get the file stats
after reading the man page for stat I thought my problem might be that I

need to use fstat since the file may be open
but that doesnt seem to work either

any suggestions would be appreciated.
my simple test program:


#!/usr/local/bin/perl


use File::stat;



my $dir_ctr = 0;
my $file_ctr = 0;


my $dir = /home/lorid/wrccpics;

  print Opening $dir \n;
 
  opendir DH, $dir  or die Can't open the current dir $!\n;
  while($file = readdir(DH)){
 
if(-d $dir/$file){  
  print \n Dir: $file \n;
  $dir_ctr++;
}
elsif(-e $dir/$file){  
  print \nFile: $file \n;  
 ( $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, 
$mtime, $ctime, $blksize, $blocks ) = stat($file);
  print \n $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, 
$atime,Mtime: $mtime,\n Ctime:$ctime,\n $blksize, $blocks\n;
  $file_ctr++;
}

  }

print \n;
print number of directories: $dir_ctr;
print \n;
print number of files: $file_ctr;

print \n;
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: send output to a parallel port?

2005-07-20 Thread robert


 -Original Message-
 From: Ken Cornetet
 
 Writing to an IO port from a user program isn't allowed under 
 NT/2k/XP.
 
 To do this you need some sort of driver.
 
 Check out http://www.winfordeng.com/products/portio32/#samples
 

well somehow the single line of C code

outp(0x378,state)

writes to the parallel port on any of our Win98 and WinXP machines.  the
single line of C is compiled all by itself (with the conio.h header of
course) 

perhaps there is some sort of driver installed allowing this low level
access, but it is transparent to the above C code.  

anyhow, my thought is that Perl would have a similar ability.

(BTW, I searched all network drives and my local drive for the example
portio32.dll, but found nothing.)

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: CGI Error message

2005-07-20 Thread Goh Chin Tiong
Kindly advise on how we can disable the following
error from appearing on the browser when a
non-existent cgi script is being called. Thanks

CGI Error
The specified CGI application misbehaved by not
returning a complete set of HTTP headers. The headers
it did return are: 
Can't open perl script
e:\Inetpub\scripts\customs\log\mini_logger.cgi: No
such file or directory





__ 
Do you Yahoo!? 
New and Improved Yahoo! Mail - 1GB free storage! 
http://sg.info.mail.yahoo.com
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: CGI Error message

2005-07-20 Thread Chris Wagner
If you're using Apache u can set an error handler to display an html
document when that particular code is encountered.  Don't know about IIS or
others, lah.


At 12:24 PM 7/21/05 +0800, Goh Chin Tiong wrote:
Kindly advise on how we can disable the following
error from appearing on the browser when a
non-existent cgi script is being called. Thanks

CGI Error
The specified CGI application misbehaved by not
returning a complete set of HTTP headers. The headers
it did return are: 
Can't open perl script
e:\Inetpub\scripts\customs\log\mini_logger.cgi: No
such file or directory





--
REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =--
...ne cede males

0100

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs