Discussion:
Help - In crunch Situation Print to file append Windows or Linux
Paul Kraus
2003-11-20 17:27:17 UTC
Permalink
Ok I am in a crunch situation. I have to gather a report from a credit
card system. The system is archaic and runs on windows. On this software
I have to go in for each day since January and print a report ( you can
not do this as a batch :( grrrrr some programmer should be shot, twice).
I want to print the data for each day to a file and append as I go. This
is labor some using windows. Almost impossible.... I can cut copy into a
new document but you can see how that could get annoying. I want it in a
text file so I can then manipulate it with perl. <-- See on topic :)

Is there some way to setup a print to file printer in windows that will
by default append and not ask for a file name? I know how to just set it
up with out that criteria but that is of no help to me.

If windows can not do this can I setup up a similar print to file
printer in Linux using cups. Share the printer using samba and then just
have the winbox print to it? If so how. I know this is kind of off
topic. But not sure where else to go. And after all it is for perl
later.
I can figure out the samba portion I just need help with setting up the
printer itself in cups.

Not to mention I think other people could benefit from this on the list.

Thanks in advance.
Paul
Bakken, Luke
2003-11-20 17:42:21 UTC
Permalink
Post by Paul Kraus
Ok I am in a crunch situation. I have to gather a report from
a credit card system. The system is archaic and runs on
windows. On this software I have to go in for each day since
January and print a report ( you can not do this as a batch
:( grrrrr some programmer should be shot, twice). I want to
print the data for each day to a file and append as I go.
This is labor some using windows. Almost impossible.... I can
cut copy into a new document but you can see how that could
get annoying. I want it in a text file so I can then
manipulate it with perl. <-- See on topic :)
Is there some way to setup a print to file printer in windows
that will by default append and not ask for a file name? I
know how to just set it up with out that criteria but that is
of no help to me.
http://www.cs.wisc.edu/~ghost/redmon/

Use redmon to set up a re-direct port. Redirect to a perl program that
opens a file for append and appends the print data to it. If you're
opening the data in MS Word (I can't tell from your description if you
are) you can use OLE to automate printing in Word from Perl.

Luke
Paul Kraus
2003-11-20 19:05:24 UTC
Permalink
Post by Bakken, Luke
http://www.cs.wisc.edu/~ghost/redmon/
Use redmon to set up a re-direct port. Redirect to a perl program that
opens a file for append and appends >the print data to it. If you're
opening the data in MS Word (I can't tell from your description if you
Post by Bakken, Luke
are) you can use OLE to automate printing in Word from Perl.
Wow this is exactly what I needed. I am having some trouble setting it
up. I am redirecting it to perl script...

#!/usr/bin/perl

use strict;
use warnings;
open (OUT,">>out.txt");
while (<>){
print OUT $_;
}


And here is the log file
RedMon - Redirection Port Monitor
Copyright (C) 1997-2001, Ghostgum Software Pty Ltd. All Rights
Reserved.
2001-10-28 Version 1.7
Environment:
ALLUSERSPROFILE=C:\Documents and Settings\All Users
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=PKRAUS
ComSpec=C:\WINDOWS\system32\cmd.exe
NUMBER_OF_PROCESSORS=1
OS=Windows_NT
Path=C:\program files\texmf\miktex\bin;C:\Perl\bin\;c:\Program
Files\Perl\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C
:\Program Files\ATI Technologies\ATI Control Panel;c:\Program
Files\Perl\perl2exe
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 15 Model 2 Stepping 7, GenuineIntel
PROCESSOR_LEVEL=15
PROCESSOR_REVISION=0207
ProgramFiles=C:\Program Files
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\WINDOWS\TEMP
TMP=C:\WINDOWS\TEMP
USERPROFILE=C:\Documents and Settings\LocalService
windir=C:\WINDOWS
REDMON_PORT=RPT1:
REDMON_JOB=33
REDMON_PRINTER=Generic / Text Only
REDMON_MACHINE=\\PKRAUS
REDMON_USER=pdk
REDMON_DOCNAME=Test Page
REDMON_FILENAME=
REDMON_SESSIONID=0

StartDocPort: failed to start process
Port = RPT1:
Command = "C:\Documents and Settings\pdk\My Documents\perl
code\redirect\redirect.pl"
Error = 193
REDMON StartDocPort: returning 0
"C:\Documents and Settings\pdk\My Documents\perl
code\redirect\redirect.pl"
Printer=Generic / Text Only
JobId=33
Level=1
DocumentName="Test Page"
OutputFile=""
Datatype="(null)"
output=0 show=0 delay=300 runuser=0

Any thoughts???

Paul Kraus
Andrew Gaffney
2003-11-20 18:15:35 UTC
Permalink
Post by Paul Kraus
Ok I am in a crunch situation. I have to gather a report from a credit
card system. The system is archaic and runs on windows. On this software
I have to go in for each day since January and print a report ( you can
not do this as a batch :( grrrrr some programmer should be shot, twice).
I want to print the data for each day to a file and append as I go. This
is labor some using windows. Almost impossible.... I can cut copy into a
new document but you can see how that could get annoying. I want it in a
text file so I can then manipulate it with perl. <-- See on topic :)
Is there some way to setup a print to file printer in windows that will
by default append and not ask for a file name? I know how to just set it
up with out that criteria but that is of no help to me.
If windows can not do this can I setup up a similar print to file
printer in Linux using cups. Share the printer using samba and then just
have the winbox print to it? If so how. I know this is kind of off
topic. But not sure where else to go. And after all it is for perl
later.
Does this program output straight text or formatted output? If its formatted, I think
you're just going to get a bunch of gobbeltygook in your file. Either way, Windows may
send PS or PCL to the printer anyway.
--
Andrew Gaffney
Jenda Krynicky
2003-11-20 18:44:14 UTC
Permalink
Post by Paul Kraus
Ok I am in a crunch situation. I have to gather a report from a credit
card system. The system is archaic and runs on windows. On this
software I have to go in for each day since January and print a report
( you can not do this as a batch :( grrrrr some programmer should be
shot, twice).
How does the system store the data? If they have it in a MS Access
(.mdb), dBase or FoxBase (.dbf) or Paradox (.db) it might be quicker
to access the data directly via DBI+DBD::ODBC or DBI+DBD::XBase and
generate the report yourself in whatever format you need.

Been there, done that.

Jenda

===== ***@Krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
Paul Kraus
2003-11-20 19:10:43 UTC
Permalink
Post by Jenda Krynicky
How does the system store the data? If they have it in a MS Access
(.mdb), dBase or FoxBase (.dbf) or Paradox (.db) it might be quicker
to access the data directly via DBI+DBD::ODBC or DBI+DBD::XBase and
generate the report yourself in whatever format you need.
Been there, done that.
Some proprietary encrypted data file.

Paul

PS
Off list can someone point me to some info on how to get outlook to
bottom post on replies.
Paul Kraus
2003-11-20 19:06:22 UTC
Permalink
Almost forgot this is plain text data.
Post by Bakken, Luke
http://www.cs.wisc.edu/~ghost/redmon/
Use redmon to set up a re-direct port. Redirect to a perl program that
opens a file for append and appends >the print data to it. If you're
opening the data in MS Word (I can't tell from your description if you
Post by Bakken, Luke
are) you can use OLE to automate printing in Word from Perl.
Wow this is exactly what I needed. I am having some trouble setting it
up. I am redirecting it to perl script...

#!/usr/bin/perl

use strict;
use warnings;
open (OUT,">>out.txt");
while (<>){
print OUT $_;
}


And here is the log file
RedMon - Redirection Port Monitor
Copyright (C) 1997-2001, Ghostgum Software Pty Ltd. All Rights
Reserved. 2001-10-28 Version 1.7
Environment:
ALLUSERSPROFILE=C:\Documents and Settings\All Users
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=PKRAUS
ComSpec=C:\WINDOWS\system32\cmd.exe
NUMBER_OF_PROCESSORS=1
OS=Windows_NT
Path=C:\program files\texmf\miktex\bin;C:\Perl\bin\;c:\Program
Files\Perl\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C
:\Program Files\ATI Technologies\ATI Control Panel;c:\Program
Files\Perl\perl2exe
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 15 Model 2 Stepping 7, GenuineIntel
PROCESSOR_LEVEL=15
PROCESSOR_REVISION=0207
ProgramFiles=C:\Program Files
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\WINDOWS\TEMP
TMP=C:\WINDOWS\TEMP
USERPROFILE=C:\Documents and Settings\LocalService
windir=C:\WINDOWS
REDMON_PORT=RPT1:
REDMON_JOB=33
REDMON_PRINTER=Generic / Text Only
REDMON_MACHINE=\\PKRAUS
REDMON_USER=pdk
REDMON_DOCNAME=Test Page
REDMON_FILENAME=
REDMON_SESSIONID=0

StartDocPort: failed to start process
Port = RPT1:
Command = "C:\Documents and Settings\pdk\My Documents\perl
code\redirect\redirect.pl"
Error = 193
REDMON StartDocPort: returning 0
"C:\Documents and Settings\pdk\My Documents\perl
code\redirect\redirect.pl"
Printer=Generic / Text Only
JobId=33
Level=1
DocumentName="Test Page"
OutputFile=""
Datatype="(null)"
output=0 show=0 delay=300 runuser=0

Any thoughts???

Paul Kraus
Bakken, Luke
2003-11-20 19:09:05 UTC
Permalink
Post by Paul Kraus
Almost forgot this is plain text data.
Post by Bakken, Luke
http://www.cs.wisc.edu/~ghost/redmon/
Use redmon to set up a re-direct port. Redirect to a perl
program that
Post by Bakken, Luke
opens a file for append and appends >the print data to it. If you're
opening the data in MS Word (I can't tell from your description if you
Post by Bakken, Luke
are) you can use OLE to automate printing in Word from Perl.
Wow this is exactly what I needed. I am having some trouble
setting it up. I am redirecting it to perl script...
#!/usr/bin/perl
use strict;
use warnings;
open (OUT,">>out.txt");
while (<>){
print OUT $_;
}
Looks good.
Post by Paul Kraus
StartDocPort: failed to start process
Command = "C:\Documents and Settings\pdk\My Documents\perl
code\redirect\redirect.pl"
Don't put it in a directory whose path has spaces in it. Just put it in
c:\windows or c:\winnt or something :-)

Also, have you set up the .pl extension correctly? If so and it still
doesn't work, try calling perl explicitly on the .pl file with a full
path to the perl executable.

Luke
Paul Kraus
2003-11-20 19:18:00 UTC
Permalink
Post by Bakken, Luke
Don't put it in a directory whose path has spaces in it. Just put it in
c:\windows or c:\winnt or something >:-)
Post by Bakken, Luke
Also, have you set up the .pl extension correctly? If so and it still
doesn't work, try calling perl >>.explicitly on the .pl file with a full
path to the perl executable.

Ok new error :)

<snip>
StartDocPort: failed to start process
Port = RPT1:
Command = "c:\perl\bin\perl C:\redirect.pl"
Error = 123
The filename, directory name, or volume label syntax is incorrect.

<full debug>
RedMon - Redirection Port Monitor
Copyright (C) 1997-2001, Ghostgum Software Pty Ltd. All Rights
Reserved.
2001-10-28 Version 1.7
Environment:
ALLUSERSPROFILE=C:\Documents and Settings\All Users
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=PKRAUS
ComSpec=C:\WINDOWS\system32\cmd.exe
NUMBER_OF_PROCESSORS=1
OS=Windows_NT
Path=C:\program files\texmf\miktex\bin;C:\Perl\bin\;c:\Program
Files\Perl\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C
:\Program Files\ATI Technologies\ATI Control Panel;c:\Program
Files\Perl\perl2exe
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 15 Model 2 Stepping 7, GenuineIntel
PROCESSOR_LEVEL=15
PROCESSOR_REVISION=0207
ProgramFiles=C:\Program Files
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\WINDOWS\TEMP
TMP=C:\WINDOWS\TEMP
USERPROFILE=C:\Documents and Settings\LocalService
windir=C:\WINDOWS
REDMON_PORT=RPT1:
REDMON_JOB=35
REDMON_PRINTER=Generic / Text Only
REDMON_MACHINE=\\PKRAUS
REDMON_USER=pdk
REDMON_DOCNAME=Test Page
REDMON_FILENAME=
REDMON_SESSIONID=0

StartDocPort: failed to start process
Port = RPT1:
Command = "c:\perl\bin\perl C:\redirect.pl"
Error = 123
The filename, directory name, or volume label syntax is incorrect.

REDMON StartDocPort: returning 0
"c:\perl\bin\perl C:\redirect.pl"
Printer=Generic / Text Only
JobId=35
Level=1
DocumentName="Test Page"
OutputFile=""
Datatype="(null)"
output=0 show=0 delay=300 runuser=0

Loading...