How to start an application on the server from a webpage - apache

Example:
The user login to the webpage => Click on a button
This action starts the executable "CreatePrettyPicture"
The file "prettypicture.jpg" is created on the server
When the user reloads the page the pretty picture "PrettyPicture.jpg" is shown on the page.
If I could start the application with a parameter it would be even better.
The server is a using Debian and as web server I'm using Apache. Please let me know if you need more information about the server configuration.
The possibility of several users clicking on the button at the same time is not a part of the problem.

You need to read up on CGI Scripts.
It's also possible that PHP is already available on your server, but I wouldn't recommend using it unless you're already familiar with it and know all of the security pitfalls, which from the question appears very unlikely.

You would be better of using a server side script with your apache installation to start the executable. This is probably easier with PHP (which should be easy to install if it isnt already), here are the commands. As long as you dont actually use any input with the page it should be safe enough.

Related

Trigger more than one URL after IntelliJ Run configuration is run

I have a Run configuration which builds an exploded web app, deploys it to tomcat, and opens the home page after that. However, I want to hit a few URLs to set some state in the app before opening the home page (Or after opening the homepage; it does not matter). Is there a way to trigger a few URL hits after the run configuration? This feature would be similar to "before launch." Instead, it would be "after launch".
There is no such feature at the moment, you can vote for the related feature request.
It's not as simple as it looks since it's not clear what would trigger the after event. The app server doesn't exit/terminate, but is still running, therefore it's not possible to use another run configuration with your app server added in its Before launch steps, otherwise you could create a Shell script configuration that would call curl/wget.
For the app server the proper after event would be the moment when the artifact deployment is complete which requires the tight integration with this specific app server so that IDE knows the exact moment when it happens and allows to call some custom action.
This might be possible with the custom plug-in as IDE already knows when the artifact deployment is complete.
A really hacky workaround would be to run some tiny HTTP server and open its URL from the IDE instead of your real app server. This custom server would call the URLs/APIs you need and then open a browser for your real app URL.

How to terminate an EventSource CGI?

A bit unsure where to look for this one...
Context:
HTML5 web page, that uses HTML5 EventSource / server-side events to get refresh notifications
OpenWrt BarrierBreaker server, running uHTTPd as the web server
a two-level CGI script that provides the server-side events:
the CGI is a shell script (ash, not bash), that parses QUERY_STRING, and calls...
a C application that do the true data extraction (from an SQLite database) and pushes the data to the web page
Everything works, except for a little detail: when the web page is closed,
the C application keeps running. Since it doesn't expect any user input, its current structure is a simple while(1). So after some time, the openwrt box has dozens of copies of the app running.
So the question: how can the application be changed to detect that the client isn't there anymore, and that it should quits?
Thanks
[Edit]
Since posting this a few hours ago, i investigated if the information was somehow available in the script's input stream. It appears it isn't.
I also found http://html5doctor.com/server-sent-events/ that describes a strategy to do exactly this in a Node.js environment, but I have no idea how to translate this in a script-based one.
[/Edit]

how to use the same login for wordpress and my flex builder 4.6 desktop app

I am a novice so please help me a bit.
I am using Flex Builder 4.6 to make a desktop app, I want to make people login before they can access the app, I want them to login with the same user info they use on my wordpress site, The database is hosted via godaddy and i have all the phpmyadmin information. I have googled and googled but I am either not doing the right set of words or this isn't possible because I cant find any examples on how to do this.
right now its a blank app with a username and password text input along with a button to login.
I'm afraid that you can't do this directly and would need to leverage Java (or similar) such as using a server application.
I've never seen or heard of anyone doing this directly via AIR. I suppose it's theoretically possible, albeit not trivial.
Edit:
Thinking about it...this would probably be a kludgy/hacky solution, you could try leveraging Java directly from the users PC by packaging a Java "service utility" with your overall install process, which would interface with your AIR Flex app. They'd need to have Java installed, and additional firewall permissions could be a pain.
You'd need to use NativeProcess.

Restarting only a portion of a rack/Sinatra app

The great thing about PHP is that if you have something like
clothes.com, clothes.com/men.php, clothes.com/women.php
Then if you only edit the men's page, only that particular "app" will be restarted.
But on rack/Sinatra I have to touch the restart.txt file to restart the ENTIRE website.
Is there a way around this problem, so that users browsing other parts of the site wont have any problems while another part of the site get edited?
(i'm using mod-passenger on Apache, not that it's important..)
This would be true in all cases anyway for editing (non-inline) views (not layouts).
Aside from that, if you're really worried about this then I'd suggest using versioned folders to hold the application code. When you do a deployment, change the proxy to point at the newer version. Those who had already made requests will remain on an instance of Apache and the application that is already running, as long as their request remains alive, and seemlessly (unless you've broken something with the code) move to the new code on the next request.
It's also a convenient way to rollback to the/a previous version quickly and easily.
Check out the sinatra reloader from sinatra contrib

Use of server side MsgBox() is wrong in web application?

I have a web application based on vb.net
I used MsgBox() in my MYPage.aspx.vb where my expectation is that the user on client should click on a button and based on it I would process further.
But I heard a suggestion the MsgBox() is working fine in my code cause on developer machine(my dev box) webserver is running locally. This does not work on a remote web server or in any hosted environment outside of a local server.
Is this true?
Is this true?
Yes. Server side code is executed on the server. The VB.NET Code Behind is executed on the server. You were seeing it on your development station because the server and client were the same machine.
If someone else were to browse to your server from another client, the dialog box would appear on the server and the user would never see it.
If you need to do a confirmation to the user, you need to use some sort of clientside code, like JavaScript and confirm.
There is no MessageBox in a web environment. It wouldn't make much sense to show a MessageBox on the server, but it compiles anyway.
So you either need to use a jQuery approach or a simple alert:
ScriptManager.RegisterStartupScript(page, page.GetType(), "MyScript", "alert('Hello World');", true)