We help IT Professionals succeed at work.

Web & EXE

SaLz
SaLz asked
on
433 Views
Last Modified: 2010-04-05
Hi, I'm looking for help on how I could send a link to an exe and have the exe execute a command.


I put my web.exe onto my web server, I make a web page with a form. the action of the post would be towards my web.exe

<form name="form1" method="post" action="web.exe">
  <input name="start" type="text" id="start" value="yes" size="10" maxlength="5">
  <input type="submit" name="Submit" value="Submit">
</form>

once my exe has accepted the post it would do something like send a command or anything,

I need to know how I can send a querystring like "web.exe?start=yes" on a web server and my program would begin a command within the procedure.

Could anyone help me with this?

Sal.
Comment
Watch Question

Russell LibbySoftware Engineer, Advisory
CERTIFIED EXPERT
Top Expert 2005

Commented:

Sal,

Sounds like what your after is a cgi program, which can be easily built with the project templates in delphi. The cgi program (WebModule) should have 1 WebActionItem added to it, and should have its default property set to true, as well as the MethodType set to mtPost. This allows it to handle any post requests that come in. Final result is that you end up with a program, eg named Web.exe that is a cgi program. When the cgi program is loaded and the action is triggered, you handle whatever you need to do in the OnAction event.

ie:

procedure TWebModule1.WebModule1WebActionItem1Action(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin

end;

the request object allows you to access the query params (among other things), which you can use to determine what it is that the program should do.

At this point in the event handling, you can pretty much do whatever you want. Start another process, whatever....

Side note: when placing this exe on the web server, you need to make sure that the web server allows for program execution on the specified directory or for the specific program. How this is done varies between web servers, but if its IIS related, and you have questions, I can help you there.


Hope this helps,
Russell

Author

Commented:
do you have or know any samples for this?
Russell LibbySoftware Engineer, Advisory
CERTIFIED EXPERT
Top Expert 2005

Commented:
Sal,
I can put together a sample if you can tell me 2 things:

1.) what web server platform are you targeting
2.) what version of delphi are you using (I have raw cgi code for console applications on Delphi 3)

I know that in my D5 demo directory, there is a webserv\iservcgi project that is used to demonstrate cgi technology. It is a bit overkill for a learning demo, but it is there nonetheless.

Anyways, I can put something simple together for you to illustrate the key points of use.

Russell

Author

Commented:
ok kool, thanks, do you want to email it to me? or will you upload it to a web site and I can download it.

The web server is ASP/PHP Envisage, so it can run both, I also have one with just php, which I use allot, both are on Microsoft Windows 2003 Server.

I'm currently using Delphi 7.

Thanks. :)
Sal.
Russell LibbySoftware Engineer, Advisory
CERTIFIED EXPERT
Top Expert 2005

Commented:

I will post the project code here (for the benfit of others), as the source should not be that long.

Russell

Author

Commented:
ok kool thankyou.

Sal.
Software Engineer, Advisory
CERTIFIED EXPERT
Top Expert 2005
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Eddie ShipmanAll-around developer
CERTIFIED EXPERT

Commented:
Check out the tutorials on Shiv Kumar's Delhi apostle site:
http://www.matlus.com

Author

Commented:
Works perfect, thanks Russell :)

Sal.
Russell LibbySoftware Engineer, Advisory
CERTIFIED EXPERT
Top Expert 2005

Commented:

Very welcome Sal,
Russell

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.