DaemonForums  

Go Back   DaemonForums > Other Operating Systems > Other OS

Other OS Any other OS such as Microsoft Windows, BeOS, Plan9, Syllable, and whatnot.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 17th December 2008
drhowarddrfine drhowarddrfine is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 377
Default Windows scripts can't print

I've spent over a week on 7 different forums, including Microsoft's own VBScript forum, trying to find someone who can help me write a simple script that downloads a page from a specific URL and automatically print it on a secondary printer (not the default). After all that, I found out vbscript can only print on the default. I might be able to change the default, then print, but that would conflict with other software.

Someone wrote one for me (I don't know vbscript) but it only prints on the default. I'd bet I can get this to work on fbsd with 10 lines or so of bash but I'm being told to get a Windows box, download the .NET platform, learn it all, then write my own. Those who are more helpful give me pointers on where to look in the docs but it either doesn't do what I want or is far more involved than I care for.

If someone here knows of a simpler way to do this, I'd appreciate it, but
<rant>
For all the hype of .NET and Windows tools, and how many people act like they know so much about all that and how wonderful it all is....well....you know how I feel.
</rant>
Reply With Quote
  #2   (View Single Post)  
Old 17th December 2008
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Tcpdump Spy
 
Join Date: Apr 2008
Location: Netherlands
Posts: 2,243
Default

Can't you use another programming language, for example, I found this promising looking results on google for python:
http://newcenturycomputers.net/proje...sprinting.html

I haven't tried it, I have I time I can try it at work tomorrow.
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
  #3   (View Single Post)  
Old 17th December 2008
drhowarddrfine drhowarddrfine is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 377
Default

I would but then I'd have to install Python, or some other language. The idea behind this project is to have minimum messing with the computer. I am positive I won't be allowed to do more than put some script or executable on this WindowsXP box. It's a cash register for a franchised operation and they get very touchy.
Reply With Quote
  #4   (View Single Post)  
Old 18th December 2008
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,125
Default

Cannot you just do a copy myfile LPT2?

With Borland Delphi for Win95 you could use a TPrintDialog component so the user could select an alternate printer. Delphi generated quite small executables IIRC

Could Java be an option?
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #5   (View Single Post)  
Old 18th December 2008
drhowarddrfine drhowarddrfine is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 377
Default

User shall not select anything. This all happens in the background. Will you give me Delphi for free and teach me how to use it?
Reply With Quote
  #6   (View Single Post)  
Old 18th December 2008
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,125
Default

Although it is Delphi Professional, it only works on Win95. It is a no-go on Win98 and up
I cannot teach you, didn't use it for more then 8 years

See http://en.wikipedia.org/wiki/Borland_Delphi and http://en.wikipedia.org/wiki/CodeGear

http://cc.codegear.com/free/delphi has Delphi Explorer editions which are free for download.
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #7   (View Single Post)  
Old 29th December 2008
roddierod's Avatar
roddierod roddierod is offline
Real Name: Rod Person
VPN Cryptographer
 
Join Date: Apr 2008
Location: Pittsburgh, Pa
Posts: 437
Default

Did you find and answer to this? If not this may help you, there are a few caveats though:

1) I don't write VB.Net/VBScript so this is a translation of C# Net to VB.
2) I'm not sure if VB.Net and VBScript actually are interchangable.
3) I would never use .Net for what your trying to do, I'd use python or something without all the .mess.
4) untested by me

Code:
Dim pd As New PrintDocument()
AddHandler pd.PrintPage, AddressOf pd_PrintPage
' Specify the printer to use.
pd.PrinterSettings.PrinterName = printer
__________________
"The basic tool for the manipulation of reality is the manipulation of words. If you can control the meaning of words, you can control the people who must use the words." -Philip K. Dick
Reply With Quote
  #8   (View Single Post)  
Old 29th December 2008
drhowarddrfine drhowarddrfine is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 377
Default

I'd try it but for now I've moved on. They have fax machines in all their locations so I'll just fax it to them till it becomes worthwhile to pay some Windows guy to code it for me.

It's a sad state of affairs I'd have to pay someone to write code that takes 10 lines or so of bash.
Reply With Quote
  #9   (View Single Post)  
Old 25th March 2009
diw's Avatar
diw diw is offline
Port Guard
 
Join Date: Jul 2008
Posts: 45
Default

Quote:
Originally Posted by drhowarddrfine View Post
It's a sad state of affairs I'd have to pay someone to write code that takes 10 lines or so of bash.
It's not what you know it's who you know (and what they know). :]

How about something much simpler than vbscript. A batch file.
You will need wget - Microsoft of course does not provide such useful utilities.

path.to\wget -O path.to\filename URI
print /d:device path.to\filename

For instance this works for me:
wget -O filename http://www.daemonforums.org/index.php
type filename

I have not used path.to as I am running the batch file from the same directory (folder) as wget. :]
I also don't have a printer so I am using "type" to output to the screen.

/d:device works on local or network printers:
Specifies the name of the print device. Valid values for parallel ports are LPT1, LPT2, and LPT3. Valid values for serial ports are COM1, COM2, COM3, and COM4. You can also specify a network printer by its sharename (\\servername\print_share). The default value is PRN. The values PRN and LPT1 refer to the same parallel port.

Using wget is probably quite easy for you (I am new to it) and also very configurable.

This is a very simple batch file.
If you need anything more (logfiles, filenames based on URI, filenames based on timestamps, etcetera) let me know.
Believe it or not, the CLI in windows does a lot of stuff similar to sh.

Best wishes.
Reply With Quote
Old 29th March 2009
drhowarddrfine drhowarddrfine is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 377
Default

I'm not allowed to download and install anything like wget on these Windows boxes. However I might like to try what you have and see if it does what I want. Will the print part of your code try and print anything if there is nothing fetched by wget? I don't recall if wget just creates a file of zero length when it saves it.

Right now I use wget on my fbsd box for this. It fetches the page and faxes it. In something less than 20 lines of bash.
Reply With Quote
Old 30th March 2009
diw's Avatar
diw diw is offline
Port Guard
 
Join Date: Jul 2008
Posts: 45
Default

Quote:
Originally Posted by drhowarddrfine View Post
Will the print part of your code try and print anything if there is nothing fetched by wget? I don't recall if wget just creates a file of zero length when it saves it.
I tried to wget a non-existent file and it creates a 0 byte file with the name from the -0 switch.
I suspect (I don't print on Windows much) that it will try to print this. In fact I am sure of it.

Perhaps the biggest limitation of the Windows CLI is it is not complex enough to manipulate output streams in more than one way at a time.
For instance, to check the output of a tracert (traceroute) for a string is trivial. To also redirect that stream to a file is not. Of course the solution in that case is to redirect the stream to a file first and then look for the string in the file. :]
In the case of wget it does not write error messages (e.g. "404 Not Found") to the file.
As I said, I am new to wget and the documentation is ... well ...
I will have a better look later.

Still, the cheap and dirty solution is to let wget run and then test the file. :]
Code:
wget -O filename http://www.nowhere.net/nothing.html
findstr ".*" filename && goto COOL
type error_message && exit
:COOL
type filename && exit
Of course again, substitute "print" for "type".
In this case there is a ready to go error_message file.
findstr ".*" - look for any character repeated any number of times.
Something nicer would be to store the URI as a variable and to append/prepend it as a footer/header on the error_message. Simple to do.

Keep me updated. I like writing batch files.

Best wishes.
Reply With Quote
Old 30th March 2009
diw's Avatar
diw diw is offline
Port Guard
 
Join Date: Jul 2008
Posts: 45
Default

Quote:
Originally Posted by drhowarddrfine View Post
I'm not allowed to download and install anything like wget on these Windows boxes.
As long as the printer is a network share, you can of course do this (wget) on any machine and send it on to the appropriate printer.

Best wishes.

EDIT:
If the file is available via ftp this simplifies things further.
An ftp client is included on every Windows I know of.
And it works pretty much like *nix ftp. Even using *nix commands ("ls" instead of "dir" for example).

Last edited by diw; 30th March 2009 at 03:31 AM. Reason: Added ftp note.
Reply With Quote
Old 30th March 2009
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Default

the only big difference is Windows ftp client lacks the filename completion and better ascii/binary awareness of BSDs.

It's also possible to feed the ftp client a script with the -s:filename switch - basically like the I/O redirection of a unix shell would allow.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
Old 30th March 2009
drhowarddrfine drhowarddrfine is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 377
Default

The printer and the Windows box are standalone and do not have static IPs. The problems mentioned above about the shell in Windows also apply to VBScript. Also, are there any problems printing to the secondary printer when a job is running, or sent, to the primary printer?
Reply With Quote
Old 30th March 2009
ephemera's Avatar
ephemera ephemera is offline
Knuth's homeboy
 
Join Date: Apr 2008
Posts: 537
Default

Quote:
Originally Posted by drhowarddrfine View Post
I've spent over a week on 7 different forums, including Microsoft's own VBScript forum, trying to find someone who can help me write a simple script that ...
Did you try stackoverflow.com?
Reply With Quote
Old 31st March 2009
diw's Avatar
diw diw is offline
Port Guard
 
Join Date: Jul 2008
Posts: 45
Default

Quote:
Originally Posted by drhowarddrfine View Post
Also, are there any problems printing to the secondary printer when a job is running, or sent, to the primary printer?
Now it's turning into the original scenario.
Quote:
Originally Posted by drhowarddrfine View Post
I've spent over a week on 7 different forums, including Microsoft's own VBScript forum, trying to find someone who can help me write a simple script that downloads a page from a specific URL and automatically print it on a secondary printer (not the default).
I think this is do-able.
Post your bash script so I know where you are at.

Apologies for not reading one of your earlier posts where you specifically say you can't install wget or other on these boxes.
Of course with a moving target (dynamic - more importantly not shared) this makes it hard to wget from your end and shovel the file on to them.

I suppose since you didn't say "yes ftp, ftp" that the file is not available via ftp.

A batch file for http will require either:
Installing wget on the client. Home and hosed.
Without installing wget on the client - either they need to be accessible to you (you push the file you wgot to their printer) or you need to be accessible to them (they retrieve the file you wgot from you).

Let me read between the lines.
They are grabbing a file from your company?
Put it on ftp.
They already have ftp (part of windows), you have a domain - ipso facto - they can access your file over the internet already via a batch file.
They can print locally to any printer they like via a batch file.
I am happy, you are happy, everyone gets rich.

Post the bash script.

Best wishes.

Last edited by diw; 31st March 2009 at 09:04 AM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't load any scripts in ircII guitarscn General software and network 4 22nd November 2010 12:06 AM
Periodic scripts for mail scripts stukov FreeBSD General 2 8th March 2009 07:51 PM
Can't Print (Fresh First Time install) BSD newb Xero FreeBSD Installation and Upgrading 4 15th February 2009 07:11 PM
Print on remote WinXP from web host drhowarddrfine General software and network 5 13th October 2008 05:41 PM
FBSD emulating pdc w/ AD, exchange and print server? cgc2 FreeBSD General 9 16th July 2008 04:14 PM


All times are GMT. The time now is 03:34 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick