Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CFEXECUTE - MS-DOS Copy Command

104 views
Skip to first unread message

John_Matlock

unread,
Jul 10, 2003, 12:49:10 PM7/10/03
to
I have a string - MyString

I can write it to disk using CFFILE -- MyString.txt

I can get out of the browser and go to MS-DOS prompt.

I type copy c:\mystring.txt lpt1

I get exactly what I want.

How can I do this under program control on either the browser or the server.

CFEXECUTE seems to say that it can execute command line stuff. But any combination I try generates an error (sometimes a Cold Fusion error, sometimes it opens an MS-DOS window and leaves the MS-DOS window open).

I can't send the string through windows because windows eats control characters and wants to convert the ASCII characters to bit maps.

I need to run this on both Windows 98 and NT 2000 based machines.

Frustrated in the desert.

John Matlock



Dan-CFTagStore.com

unread,
Jul 10, 2003, 1:58:08 PM7/10/03
to
Hi John,

I saw you posted a few times.

I tried to re-create what you were trying but got Win NT Error 2. This is something to do with it not being able to find COPY. I then tried command.com and send the arguements COPY fileName Printer but to no avail.

This, though, works:

Create a batch file called copy.bat

copy.bat:
copy %1 %2
(%1 is the source argument, %2 is the destination)

Pop this CF code in your page:
<cfexecute name="c:\copy.bat" arguments="c:\filename.txt LPT1">
</cfexecute>

LPT1 would print to a printer connected to LPT1 on the CF server.
If you need to print to a network printer, just use the UNC
(\\server\printer)

Hope this helps you and gets you out of the desert, :-)

Regards,
Dan.

Check Out : www.cftagstore.com for the latest and greatest Coldfusion custom tags and components!

Built by developers, for developers!

John_Matlock

unread,
Jul 11, 2003, 12:35:17 PM7/11/03
to
A beautiful and elegant solution.

So simple once you see it.

I probably would have thought of it myself in about a thousand years.

Part of the problem of living in the desert is that the closest CF'er is hundreds of miles away and there is no one to point out the obvious.

A potential problem, however -- it leaves the MS-DOS window open.

If you print a hundred pages, that's a hundred open windows sitting there in the dark server room.

How do you close a window without having to click on it?

Or, since the server reboots every day, it comes up with the services running but waiting on CTL-ALT-Delete before establishing the GUI.

In this state, will it still run, attempt to leave an open window but since there is no GUI go away happy? That way, the only times a hundred windows will open is when someone goes in to do maintenance on the server.

All in all, this technique goes a long way to solving a lot of the CF printing problems.

If you are doing standard windows stuff you can use style sheets and ActiveX to control what gets printed.

If you are using non-standard stuff, in this instance multi-part tractor paper forms where you don't want windows to get in the way your approach works.

Thanks again.

The desert is breaking out in blooms (except that it is too hot - it's range fire season instead).

John


rcoleman

unread,
Oct 31, 2003, 5:12:47 PM10/31/03
to
I am having trouble getting this BAT file approach to work under CFMX 6.1.

Here is the BAT file that works from the command line:

copy e:\test.txt c:\coda_out
exit

When I try it with CF as below:

<cfexecute name="c:\coda_out\copy.bat">
</cfexecute>

no file is copied. It goes to say that $1 $2 does not work either.


HELP!!

Rick


0 new messages