LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-17-2015, 04:41 AM   #1
Talita
LQ Newbie
 
Registered: Jun 2014
Posts: 6

Rep: Reputation: Disabled
html buttons to launch server-side scripts


Hello forum members,
I'm trying to create an internal website as an interface to my (Ubuntu) server to run a number of scripts (server-side). I'm a newbie when it comes to creating websites, but what web language can I best use / study for accomplish my goal. I've already started with PHP but haven't found a way to launch server side shell / python scripts by clicking on a picture / button.

Thanks for your reply

Talita
 
Old 06-17-2015, 05:05 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Check out the system function of php or the exec funtion.

Somethings you might run into are the permissions. Normaly a webserver is run under a specific user that might not have acces to all binaries or path you like. You might solve this with a sudo line or the apropiate su module of apache (cant recall exact name right now).

If you show us what you have got so far we are able to help you out much better.
 
Old 06-17-2015, 05:35 AM   #3
Talita
LQ Newbie
 
Registered: Jun 2014
Posts: 6

Original Poster
Rep: Reputation: Disabled
Hello zhjim,

For now I've just got a basis HTML page, but I'm trying to gather the knowledge how to link the scripts (phyton) to the pictures.

Code:
<html>
	<head>
		<title>title</title>
		<link rel="stylesheet" href="BASIC.css" type="text/css">
		<style></style>
	</head>
	<body>
		<table align="center" border="0">
				<td><br></td>
				<td><img src="green_arrow_up.png"></td>
				<td><br></td>
			</tr>
			<tr>
				<td><img src="green_arrow_left.png"></td>
				<td><img src="green_dot.png"></td>
				<td><img src="green_arrow_right.png"></td>
			</tr>
			<tr>
				<td><br></td>
				<td><img src="green_arrow_down.png"></td>
				<td><br></td>
			</tr>
		</table>
	</body>
</html>
BASIC.css is still empty

Last edited by Talita; 06-17-2015 at 05:38 AM.
 
Old 06-17-2015, 06:41 AM   #4
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
You could use the on_click function of javascript. Either call a function that handles the rest or just directly call another page

Quote:
<img onclick="window.open('http://www.w3.org', '_blank')">
Or put an a tag around the img tag that loads the right page.

Why not first try to run your scripts directly? Namely create a webpage that once opened runs the script you want to. This way you don't have to fight at two fronts. After that do the img click thing. And once both parts work individualy you tie them together.
 
Old 06-17-2015, 07:05 AM   #5
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,472

Rep: Reputation: 618Reputation: 618Reputation: 618Reputation: 618Reputation: 618Reputation: 618
Here's what I do to put a button under each pic in a table
Code:
<html>
	<div align="center"
		<head>
			<title>Pyramids 3</title>
		</head>
		<body bgcolor=#ccb947>
			<h1>Pyramids 3</h1>
	</div>
	<div align="center">
		<form action="/cgi-bin/uploadimage?folder=/Photos/Pictures/PhonePics/" method="post"
			enctype="multipart/form-data">
			<input type="file" name="file" id="file">
			<input type="submit" name="submit" value="Upload File">
		</form>
	</div>
	<div <head="" align="center">
		<table cellspacing=2>
<tr valign=bottom>

			<td>
				<center>
				<a href="picture037.jpg"><img src="tmb/picture037.jpg" alt="click to enlarge"></a>
				<font size="-4"><form action="/cgi-bin/edit?name=/Photos/Pictures/PhonePics//picture037.jpg" method="post" style="padding: 0; margin: 0">
	<input type="submit" value="Edit">
</form></font>
			<td>
				<center>
				<a href="picture038.jpg"><img src="tmb/picture038.jpg" alt="click to enlarge"></a>
				<font size="-4"><form action="/cgi-bin/edit?name=/Photos/Pictures/PhonePics//picture038.jpg" method="post" style="padding: 0; margin: 0">
	<input type="submit" value="Edit">
</form></font>
			<td>
				<center>
				<a href="picture039.jpg"><img src="tmb/picture039.jpg" alt="click to enlarge"></a>
				<font size="-4"><form action="/cgi-bin/edit?name=/Photos/Pictures/PhonePics//picture039.jpg" method="post" style="padding: 0; margin: 0">
	<input type="submit" value="Edit">
</form></font>
...
and so on, this gives:
Click image for larger version

Name:	Screenshot - 170615 - 11:57:22.jpg
Views:	12
Size:	102.6 KB
ID:	18726

all the scripts are in "cgi-bin" in the root of the server and the config part of /etc/apache2/sites-available/default is
Code:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName keithhedger.darktech.org

DocumentRoot /media/Homenet/Homenet
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /media/Homenet/Homenet/cgi-bin/
<Directory "/media/Homenet/Homenet/cgi-bin/">
	AllowOverride None
	Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
	Order deny,allow
	deny from all
	Allow from 192.168.1.0/255.255.255.0
</Directory>

<Directory /media/Homenet/Homenet/user-scripts/>
	Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
	AllowOverride None
	Order allow,deny
	allow from all
</Directory>

AddHandler cgi-script .sh

</VirtualHost>
Most of the scripts are in BASH
Hope that this gives you a start.
P.S.
The 'Allow from ... ' bit is so that the scripts are only executable form the LAN and not the internet, remove that bit if you want anyone to execute your scripts.

Last edited by Keith Hedger; 06-17-2015 at 07:10 AM. Reason: add expalaination
 
Old 06-18-2015, 02:00 PM   #6
Talita
LQ Newbie
 
Registered: Jun 2014
Posts: 6

Original Poster
Rep: Reputation: Disabled
Hello Keith,

As far as I can understand your code your using a 'post' method.
So I will try to read up on that topic.
Any good suggestions to start from?

And thank-you al for your your replays!

Talita
 
Old 06-18-2015, 02:54 PM   #7
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,472

Rep: Reputation: 618Reputation: 618Reputation: 618Reputation: 618Reputation: 618Reputation: 618
Yes this is bash script for the 'uploadimage' button:
Code:
#!/bin/bash -e

#Škeithhedger Mon 23 Sep 15:50:51 BST 2013 kdhedger68713@gmail.com

waitPage ()
{
	echo "Content-type: text/html"
	echo ""
	echo "<html><head>"
	echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=$HTTP_REFERER\">"
	echo "</head>"
	echo "<body>"
	echo "<b>$1</b>"
	echo "</body></html>"
	exec >&-
}

f=$(echo $QUERY_STRING|/usr/bin/awk -F '&' '{print $1}')
FOLDER="${f/folder=/}"
waitPage "Uploading file to ${FOLDER}..."

if [ "$REQUEST_METHOD" = "POST" ];then
	TMPOUT=/tmp/fwupdate
	cat >$TMPOUT
	n=$(awk "NR==2" $TMPOUT|awk -F "=" '{print $3}')
	NAME=${n//\"/}
	NAME=${NAME:0:${#NAME}-1}

	if [ X"$NAME" = "X" ];then
		rm "$TMPOUT" $TMPOUT.1||true
		exit 0
	fi
# Get the line count
	LINES=$(wc -l $TMPOUT | cut -d ' ' -f 1)

# Remove the first four lines
	tail -$((LINES - 4)) $TMPOUT >$TMPOUT.1

# Remove the last line
	head -$((LINES - 9)) $TMPOUT.1 >$TMPOUT.jpg
	truncate --size=-2 $TMPOUT.jpg
fi

mv $TMPOUT.jpg "/media/Media${FOLDER}/${NAME}"
/media/Media/WebSite/cgi-bin/autothumb -r "/media/Media" -n "/media/Media${FOLDER}"
rm "$TEMPOUT" $TMPOUT.1

exit 0
It should give you a start on how to do some stuff, it is complicated and takes time, permissions are important, start simple and build from there, good luck.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
best client side way to include html within html entz Programming 1 09-12-2009 10:56 PM
Hiding Server Side Scripts TomalakBORG Linux - Enterprise 3 07-26-2005 03:47 PM
imwheel (side buttons) Zallus Linux - General 0 09-22-2003 01:34 AM
Side Buttons Gman22 Linux - Software 5 08-12-2003 04:16 PM
side-buttons. intellimouse ! sapilas Linux - Distributions 2 05-24-2002 05:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration