| View previous topic :: View next topic |
| Author |
Message |
jwfv Valued Contributor

Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Tue Aug 12, 2003 10:35 pm Post subject: Executing a program on a web server? |
|
|
Can this be done easily?
I have a VDS program running on the client's computer. I want it to execute a program on my web server that will quickly create a small text file on that server. Then I will use HTTP GET to retrieve that file and display or parse it, etc.
I am trying to avoid any actual web page programming, since I know very little about HTML, etc.
The program I am trying to run CAN function as a CGI program, according to the author. It extracts some data from a database table, and writes it to a text file.
I've used the HTTP and FTP functions of VDS 5 (and extensions) and really like the simplicity and ease of use.
Any ideas pointing me in the right direction are appreciated. |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Aug 13, 2003 1:43 pm Post subject: |
|
|
Well first you're going to have to request the CGI in order to execute it.
Try using a HTTP GET, discard that output, and then use HTTP GET again
to get the text file. If it's an EXE-type CGI application then you'll have to
make sure the server supports it, that it is a Windows server, and that
it has correct permissions. I hope this helps.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
jwfv Valued Contributor

Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Wed Aug 13, 2003 1:49 pm Post subject: |
|
|
Thanks for the reply.
Could I use HTTP POST to run the program? It is an executable (.exe) and not a script. Is that a problem?
Also, the program has the ability to write to standard output (and I'm getting to the limit of my knowledge here) so could I just get the program's result directly into a list I specify with HTTP POST? |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Aug 13, 2003 1:54 pm Post subject: |
|
|
Yes you can post to the CGI, it will function as a normal CGI program. Just
a different language is all. Assuming you are using the VDSIPP, you can
use @internet(http,1,content) to get the output, if you'd like to do it that
way. Really an EXE-type CGI application won't act much different.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
PGWARE Web Host

Joined: 29 Dec 2001 Posts: 1565
|
Posted: Wed Aug 13, 2003 1:56 pm Post subject: |
|
|
jwfv, you first need to see if the .exe file can run on your webserver as a cgi script. If your using Linux server then definately no you can't run an exe as a cgi. If you are on a Windows server then you may be able to depending on what the administrator of the server allows.
If the exe passes and lets you run it as a cgi then you need to determine if the cgi is accepting variables in GET mode or in PUT mode. You can then do a HTTP GET or HTTP POST metho depending on how the cgi accepts variables. Some cgi's only accept GET requests, others accept only PUT requests and theres some that accept either.
Since none of us have access to your cgi/exe you'll definately need to research this with the webserver and exe/cgi you have before we can really offer any real help, right now we're all trying to determine if you even have the right setup to get this to work.
As for writing to a listbox, well again if you use HTTP GET or POST most likely the exe/cgi will return back some sort of data. If you are using a dll to do the GET or POST then it will return back this data and you can easily assign the returned text to a listbox. |
|
| Back to top |
|
 |
jwfv Valued Contributor

Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Wed Aug 13, 2003 3:19 pm Post subject: |
|
|
I have emailed my ISP with some questions and am still waiting on a response. Here is a PHP script I got from the author of the software when I asked him about running it as a CGI program. In this example, the program simply prints all fields of each row of a database table, with fields separated by '|'. (The program essentially executes SQL-type statements on a single .DBF table.)
Does this offer any clues as to how it functions - as GET or PUT?
| Code: |
exec("cdbflite.exe test.dbf /select:*", $x);
$i=0;
while($i < count($x))
{
$string = $x[$i];
$tok = strtok($string,"|\n");
while($tok)
{
echo $tok." ";
$tok = strtok("|\n");
}
echo "<br>\n";
next($x);
$i++;
}
|
|
|
| Back to top |
|
 |
jwfv Valued Contributor

Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Wed Aug 13, 2003 4:57 pm Post subject: |
|
|
I have made some progress, I think. I can execute the program in the CGI-BIN directory on my site simply by calling it in the address line of a browser. (www.whatever.com/cgi-bin/my.exe)
It then gives me a result page, with the standard output of that program. (With a message that the headers were incorrect, which I can work with.)
I can't figure out how to pass the program any parameters, however. I feel if I could pass the parameters:
my.exe data.dbf /select:*
then I would be very close to what I want to do.
Any suggestions? |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Aug 13, 2003 5:11 pm Post subject: |
|
|
You can't really pass it parameters like you can on your PC. The way
to pass it parameters would be my.exe?param=value¶m2=value2
Try using it that way and let us know how it works.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
jwfv Valued Contributor

Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Wed Aug 13, 2003 5:40 pm Post subject: |
|
|
Doesn't seem to work - the program responds as if it didn't get any parameters.
Here is the actual command line I am trying to run, verbatim:
cdbflite.exe bptrtype.dbf /select:* |
|
| Back to top |
|
 |
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Wed Aug 13, 2003 5:53 pm Post subject: |
|
|
This just seems a normal command-line application. In order to be able to accept parameters
using CGI, the command-line program will have to be specifically programmed by
its author for this purpose, which I don't think applies for this program. |
|
| Back to top |
|
 |
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Wed Aug 13, 2003 5:55 pm Post subject: |
|
|
Actually you may be able to write a simple CGI executable in VDS that will wrap around
the database executable file in question. The VDS executable would accept the parameters
according to the CGI standard and would pass them on to the database program as
command-line parameters. |
|
| Back to top |
|
 |
jwfv Valued Contributor

Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Wed Aug 13, 2003 6:13 pm Post subject: |
|
|
Here is one more thing I have found:
There is a parameter you can pass, /VERSION, that will give the version information.
when I run
/cgi-bin/cdbflite.exe?/version
it works! I get a different output, the same one I would if running it locally.
But - how to pass two parameters?
I would love to try the VDS "wrapper" option, but I have read in the forum that it can be hard to find a web host that will allow it on a shared server. . . |
|
| Back to top |
|
 |
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Wed Aug 13, 2003 8:21 pm Post subject: |
|
|
In that case I would try this:
/cgi-bin/cdbflite.exe?bptrtype.dbf+/select:*
or
/cgi-bin/cdbflite.exe?bptrtype.dbf%20/select:* |
|
| Back to top |
|
 |
jwfv Valued Contributor

Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Wed Aug 13, 2003 8:47 pm Post subject: |
|
|
Thanks - but tried both of those options. Neither one works.
It's odd that you could run the program, and pass one parameter to it, but not be able to pass 2 parameters ... |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Aug 13, 2003 9:33 pm Post subject: |
|
|
| jwfv wrote: | Here is one more thing I have found:
There is a parameter you can pass, /VERSION, that will give the version information.
when I run
/cgi-bin/cdbflite.exe?/version
it works! I get a different output, the same one I would if running it locally.
But - how to pass two parameters?
I would love to try the VDS "wrapper" option, but I have read in the forum that it can be hard to find a web host that will allow it on a shared server. . . |
Why don't you just try a simple VDS program? Chances are is that if you
have an EXE CGI working you'll get a VDS CGI one working too. If I may
ask, which host are you using?  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
|