Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: How to run client side application via a server script? |
|
Author |
|
ejazshah
Joined: 08 Oct 2009 Posts: 2
|
Posted: Fri 09 Oct '09 9:49 Post subject: How to run client side application via a server script? |
|
|
I have a server setup on my window XP machine. It is used for uploading, downloading and deleting files(all these functionalities working fine). Now what I want is to have python scripts that perform certain task. The place where all python scripts are located is:
http://localhost:8085/test/Upload/pythonlist.php
The two scripts with the name hello.wsgi/copy of hello.py is the same file (only extension changed for test purpose.)
The complete script is as under:
def application(environ, response):
text ="Hello Everyone"
response('200 OK', [('Content-Type', 'text/plain;charset=utf-8'),('Content-Length', str(len(text)))])
return [text]
Clicking on this script(hello.wsgi or copy of hello.py) gives the output which prints Hello Everyone!!!
Now what I want is to have a script at this location(http://localhost:8085/test/Upload/pythonlist.php), clicking on which shall open up notepad for the user.
I tried using this script:
import subprocess
import os
import traceback
def application(environ, response):
try:
file.write("im here\n")
subprocess.Popen('c:\WINDOWS\notepad.exe')
except:
if traceback.print_exc(10) != None:
file.write(traceback.print_exc(10))
else:
file.write("nothing happened")
file.close()
text ="When that Aprill with his shoures soote"
response('200 OK', [('Content-Type', 'text/plain;charset=utf-8'),('Content-Length', str(len(text)))])
return [text]
The desired output is that, on clicking this script it shall print out text (not in notepad) and open up notepad.
But what it does is, it prints out the text and I dont know why it runs the notepad application in the background instead.
You cant see any notepad opening up but when you check it in task manager it shows that notepad is running.
So I would say the only problem now left is how to get the application (notepad) to run in front (as in openup notepad on click) rather than running in the back ground.
I hope it will clear out the situation as to what I am trying to do.
Kindly help me out.
Regards, |
|
Back to top |
|
paranid
Joined: 02 Mar 2009 Posts: 11
|
Posted: Fri 09 Oct '09 11:05 Post subject: |
|
|
Hello,
try to allow your Apache to use your desktop, if it is running as a service.
Services - Apache 2.2 - Properties - Log on as - Allow service to interact with desktop (I do not have english version of XP, so it can be different),
or try to run this Apache service as desired user. |
|
Back to top |
|
ejazshah
Joined: 08 Oct 2009 Posts: 2
|
Posted: Fri 09 Oct '09 20:38 Post subject: |
|
|
Hi,
Thank you so much dude. Its working for me now. But still there exist one problem. It works only on the machine on which server setup is installed and is accessed as localhost. If the script is remotely accessed and executed(by a client with all the same configurations like same OS etc) it does not work.
Can you help me on this??
Regards,
Ejaz Shah |
|
Back to top |
|
paranid
Joined: 02 Mar 2009 Posts: 11
|
Posted: Sun 11 Oct '09 16:09 Post subject: |
|
|
Hello,
sorry, I assumed you wanted to run that notepad on the same machine (server) with Apache/Python, remotely executed by that python script (when you would access a page with the browser, the notepad would be executed on the server).
The problem is that it is a server side script running on the server, when you want to run notepad on a client side (eg. access a webpage on a server, which would open/run a notepad on the client side) you need a client side script.
You need somehow force the client (browser) to run a script localy on client side. For this type of scripting you can use eg. Javascript/ActiveX,... But there are some security troubles, problems with different browsers... This is not my cup of tea, so you can try this example:
http://bytes.com/topic/javascript/answers/636730-starting-notepad-exe-webpage |
|
Back to top |
|
|
|
|
|
|