Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making an HTML webpage with button that will execute a script on the server 1

Status
Not open for further replies.

bazil2

Technical User
Feb 15, 2010
148
DE
(Elementary user)

Good morning,

Can anyone help me with the following, or point me to the correct forum?

In it's simplest terms, I have a shell script on the server that moves some files from A to B when executed.

On the same server (webserver), I would like to create an HTML page with a button that when depressed, will execute the script I've made.

Could anyone please advise?

Best regards

 
Hi

Why a button and not just a link ?

Anyway, either transform the shell script into a CGI script or create a CGI script to call the shell script. Then just link to or submit to that CGI script.

Note that when run by the web server the script will have run with the web server's user's permissions, which may not have the permissions necessary to perform the file operations.

Feherke.
[link feherke.github.com/][/url]
 
Many thanks!

Well I'd like a button purely to make it more cosmetically appealing and there may be several buttons by the time I'm finished (a couple of different scripts).

The script is executed by the crontab so I would feel uncomfortable changing it, so I would like to try your suggestion of creating a CGI script that calls the shell script.

Are you able to give me an example of a CGI script?

Best regards

 
Hi

bazil2 said:
Are you able to give me an example of a CGI script?
Yes. If it needs no input data is really simple : you just output the necessary HTTP headers. For example this Bash script will display the server machine's date & time :
Code:
[gray]#!/bin/bash[/gray]

[gray]# you have to tell how the output should be interpreted[/gray]
echo [green][i]'Content-type: text/plain'[/i][/green]
[gray]# an empty line separates the HTTP response headers and the content[/gray]
echo

[gray]# then you just generate the desired output[/gray]
echo [green][i]'Current time on the server is'[/i][/green]
date
But this is off-topic here, you can find more about CGI scripting in forum452.

Feherke.
[link feherke.github.com/][/url]
 
Thanks very much, I will try this.

Best regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top