More Batchfile fun!

This is a discussion on More Batchfile fun! within the Windows Web Servers forums, part of the Web Server and Related Forums category; Hi, since the download vs. execute bat file in Apache2 on win2k seems to have been solved (by using html ...


Go Back   Usenet Forums > Web Server and Related Forums > Windows Web Servers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-09-2003
rach
 
Posts: n/a
Default More Batchfile fun!

Hi,

since the download vs. execute bat file in Apache2 on win2k seems to have
been solved (by using html formatting), I have another question. How can I
call an exe in a batch file and have the results display in the browser.

For example, I have executed this tool:
http://www.sysinternals.com/ntw2k/freeware/psinfo.shtml inside my cgi-bin
directory like so: http://puter.com/cgi-bin/psinfo.exe? and I get these
results:

PsInfo 1.34 - local and remote system information viewer
Copyright (C) 2001-2002 Mark Russinovich
Sysinternals - www.sysinternals.com

Querying information for WORKHORSE...

System information for \\WORKHORSE:
Uptime: Error reading uptime
Kernel version: Microsoft Windows 2000, Uniprocessor Free
Product type: Professional
Product version: 5.0
Service pack: 4
Kernel build number: 2195
Registered organization: none
Registered owner: workhorse
Install date: 6/11/2003, 7:28:39 PM
IE version: 6.0000
System root: C:\WINNT
Processors: 1
Processor speed: 120 MHz
Processor type: Intel Pentium
Physical memory: 80 MB

Which is exactly how it should be.

But I'd like to know how I can call that inside a bat file, but it doesn't
work. When I have the batch file like so:

@echo off
echo Content-Type: text/html
echo.
Echo ^<HTML^>
Echo ^<HEAD^>
Echo ^<TITLE^>TEST BAT FILE^</title^>
Echo ^</head^>
Echo ^<BODY^>
Psinfo.exe
Echo ^</body^>
Echo ^</html^>

When I call it, it doesn't show any results, and in fact the browser doesn't
display anything, and my error log shows no errors. How can I get it to
execute and display the results?

Thanks!

Rach


  #2 (permalink)  
Old 07-09-2003
rach
 
Posts: n/a
Default Re: More Batchfile fun!

I see what you're saying. OK so to try that output trick I did this:

@echo off
echo Content-Type: text/html
echo.
Echo ^<HTML^>
Echo ^<HEAD^>
Echo ^<TITLE^>TEST BAT FILE^</title^>
Echo ^</head^>
Echo ^<BODY^>
Psinfo.exe > output.txt
echo ^<pre^>
type output.txt
echo ^</pre^>
Echo ^</body^>
Echo ^</html^>

When I execute this via the cmd line, it returns everything it should.
However when I execute it via the browser I don't get any data displayed.
Only the:

<HTML>
<HEAD>
<TITLE>TEST BAT FILE</title>
</head>
<BODY>
<pre>
</pre>
</body>
</html>

in the source. I look in the cgi-bin folder and output.txt is there, but
it's empty - totally blank. I wonder why this is. I know for a fact the
browser user (which is not local system BTW) has write access to the folder.
Again no errors in the logs.

Rach


[snip]
> Your exe application will need to put the lines into html format
> and send it to stdout on your computer, where it will be picked
> up by the web server and sent to the client web brouser. If your
> exe file can print its output to a txt file, then you might be
> able to call another batch file to echo each line of the txt file
> so the web server will pick them up and send them to the client
> brouser.



  #3 (permalink)  
Old 07-10-2003
rach
 
Posts: n/a
Default Re: More Batchfile fun!

[snip]
> >in the source. I look in the cgi-bin folder and output.txt is there, but
> >it's empty - totally blank. I wonder why this is. I know for a fact the
> >browser user (which is not local system BTW) has write access to the

folder.
> >Again no errors in the logs.
> >
> >Rach

>
> Even though your batch file makes the txt file, your exe program
> is probably still sending data to the monitor screen (if the dos
> box is visible) instead of the txt file. If your exe file does
> not have a command line option to print to a file, then what you
> want to do may be difficult. You might try Psinfo.exe /? and see
> what options are available.


Even if I do it in on the cmd line as well as the batch file and it outputs
to txt file, this behaves would be different in the browser executing it?
Well it would seem so but seems odd. Yah that tool doesn't have an output
option, just the default redirect ">" thingee.

Rach


  #4 (permalink)  
Old 07-10-2003
rach
 
Posts: n/a
Default Re: More Batchfile fun!

FYI: I found the answer in this newsgroup: alt.msdos.batch.nt in thread
"Batch from cgi-bin".

Then answer was this:

@echo off
echo Content-Type: text/html
echo.
Echo ^<HTML^>
Echo ^<HEAD^>
Echo ^<TITLE^>TEST BAT FILE^</title^>
Echo ^</head^>
Echo ^<BODY^>
cmd /c (Psinfo.exe ^> output.txt)
echo ^<pre^>
type output.txt
echo ^</pre^>
Echo ^</body^>
Echo ^</html^>

Works every time now! :-D


Rach



"Si Ballenger" <shb*NO*SPAM*@comporium.net> wrote in message
news:3f0c9ac7.81535511@news.comporium.net...
[snip]
> Even though your batch file makes the txt file, your exe program
> is probably still sending data to the monitor screen (if the dos
> box is visible) instead of the txt file. If your exe file does
> not have a command line option to print to a file, then what you
> want to do may be difficult. You might try Psinfo.exe /? and see
> what options are available.



 


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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:53 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0