View previous topic :: View next topic |
Author |
Message |
b123 -
Joined: 12 Oct 2004 Posts: 9
|
Posted: Sun Oct 17, 2004 7:09 pm Post subject: .BAT files as CGI scripts |
|
|
How can I use MS-DOS batch files as CGI scripts? Like this?:
Code: |
@echo off
echo Content-type: text/html
echo.
echo <HTML><BODY>
echo <b>Hello!!!</b>
echo </BODY></HTML>
echo.
|
Then add "/*.bat" to the CGI paths? |
|
Back to top |
|
|
admin Site Admin
Joined: 03 Mar 2002 Posts: 1295
|
Posted: Mon Oct 18, 2004 2:47 pm Post subject: Re: .BAT files as CGI scripts |
|
|
Yes, you can. Please contact support@aprelium.com to get a BAT files interpreter (it is simply a wrapper for BAT files execution) with many tips about how to write BAT CGI scripts. |
|
Back to top |
|
|
Pedja -
Joined: 25 Nov 2005 Posts: 9
|
Posted: Fri Nov 25, 2005 10:59 pm Post subject: |
|
|
I stumled into this topic looking for a way to run BAT as script. Is there a reason for not talking about it publicly?
I guess it would be ueful to allow bat to be executed as script, as well as any other script language integrated into operating system.
I do not why there is need to make difference. Running BAT or EXE or COM, if OS runs it, let it run, then. |
|
Back to top |
|
|
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Fri Nov 25, 2005 11:56 pm Post subject: |
|
|
Pedja wrote: | I stumled into this topic looking for a way to run BAT as script. Is there a reason for not talking about it publicly?
I guess it would be ueful to allow bat to be executed as script, as well as any other script language integrated into operating system.
I do not why there is need to make difference. Running BAT or EXE or COM, if OS runs it, let it run, then. |
Hello Pedja, welcome to the forums.
From what I can gather this function is not widely used so it doesnt seem logical to include it in the software. Plus, with it being an interpreter, it would be difficult to include it in the software anyway. This would be down to copyright issues etc. However, I would think you can add it just like you can with the php interpreter. _________________ Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Sat Nov 26, 2005 9:43 pm Post subject: |
|
|
Pedja,
Since Abyss Web Server X1/X2 version 2, running BAT scripts is possible without any external wrapper:
* Open Abyss Web Server's console. In the Hosts table, press Configure in the row corresponding to the host to which you want to add BAT support. If there is no Hosts table in the main screen of your console, this means that you are using an old version of Abyss Web Server. Please read the second part of the email in this case.
* Select "Scripting Parameters".
* Check "Enable Scripts Execution".
* Press "Add" in the "Interpreters" table.
* In the "Interpreter" field, enter C:\WINNT\SYSTEM32\CMD.EXE if you are
using Windows NT/2000/XP/2003. If you are using Windows 95/98/ME, enter
C:\windows\command.com
* Check "Use the associated extensions to automatically update the Script
Paths".
* Press "Add" in the "Associated Extensions" table.
* Enter bat in the "Extension" field and press "OK".
* Press "OK".
* Press "OK" in the "Scripting Parameters" dialog.
* Press Restart to restart the server.
Here is a small example.bat to test the settings:
Code: | @echo off
rem CGI headers
echo Content-Type: text/html
echo.
rem CGI Body
echo ^<HTML^>^<BODY^>
echo ^<PRE^>Your environment variables are:
set
echo ^</PRE^>^</BODY^>^</HTML^> |
Below are the conventions you must use when writing a CGI .bat file:
* @echo off at the beginning of the script is mandatory.
* Use echo. to write an empty line (to separate the CGI header from the CGI body).
* Use ^> and ^< with echo to write < and >. In fact, < and > are special characters and ^ is used to escape them. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
Override -
Joined: 25 Nov 2003 Posts: 124 Location: Virtual Abyss N Area 61
|
Posted: Sun Jan 22, 2006 9:46 am Post subject: |
|
|
what if you get a HTTP 500 - Internal server error |
|
Back to top |
|
|
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Sun Jan 22, 2006 10:21 am Post subject: |
|
|
Override wrote: | what if you get a HTTP 500 - Internal server error |
Check your script. Your script is causing an error. _________________ Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk |
|
Back to top |
|
|
Override -
Joined: 25 Nov 2003 Posts: 124 Location: Virtual Abyss N Area 61
|
Posted: Sun Jan 22, 2006 10:39 am Post subject: |
|
|
i did the example that aprelium did ? |
|
Back to top |
|
|
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Sun Jan 22, 2006 10:41 am Post subject: |
|
|
Did you configure the interpreter correctly? _________________ Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk |
|
Back to top |
|
|
Override -
Joined: 25 Nov 2003 Posts: 124 Location: Virtual Abyss N Area 61
|
Posted: Sun Jan 22, 2006 10:42 am Post subject: |
|
|
yes so i thought |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Sun Jan 22, 2006 1:24 pm Post subject: |
|
|
Override wrote: | yes so i thought |
Is there an error message in log/cgi.log? _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
Override -
Joined: 25 Nov 2003 Posts: 124 Location: Virtual Abyss N Area 61
|
Posted: Sun Jan 22, 2006 5:38 pm Post subject: |
|
|
Code: | CGI: [C:\WINDOWS\system32\cmd.exe example.bat ]URI: /example.bat Bad CGI header line [Microsoft Windows XP [Version 5.1.2600]] |
|
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Mon Jan 23, 2006 2:22 pm Post subject: |
|
|
Override wrote: | Code: | CGI: [C:\WINDOWS\system32\cmd.exe example.bat ]URI: /example.bat Bad CGI header line [Microsoft Windows XP [Version 5.1.2600]] |
|
This means that there is a problem with example.bat (possibly an error). What is the full output of the execution of the following command o(in Windows command line window):
Code: | cd "C:\Program Files\Abyss Web Server\htdocs"
C:\WINDOWS\system32\cmd.exe example.bat |
Replace of course C:\Program Files\Abyss Web Server\htdocs with the directory where example.bat is. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
Override -
Joined: 25 Nov 2003 Posts: 124 Location: Virtual Abyss N Area 61
|
Posted: Tue Jan 24, 2006 5:13 am Post subject: |
|
|
even if it is on a network storage unit ? |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Tue Jan 24, 2006 12:55 pm Post subject: |
|
|
Override wrote: | even if it is on a network storage unit ? |
Use the path of the network storage unit or copy example.bat on C: and run it from there. All we want to see is the error message that is output. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
paulSS -
Joined: 27 Mar 2006 Posts: 1
|
Posted: Mon Mar 27, 2006 11:28 pm Post subject: |
|
|
cmd.exe needs a /c parameter. So you need to add
/c "%1"
to the Arguments box in the Interpreters screen |
|
Back to top |
|
|
|