Solved

button or link that runs exec commands

Posted on 2004-03-24
3
446 Views
Last Modified: 2013-11-18
Hoi,

I have 5 exec comamnds like

<?php
echo exec('/tmp/run/example1.sh');
?>

How can I make a page where you ckick to activate the scripts, I don't have
GD so it can be text based.

Now it runs the scripts when the page is loaded, and that is not what I want.

Jeffeny
0
Comment
Question by:harryv
  • 2
3 Comments
 
LVL 33

Expert Comment

by:snoyes_jw
ID: 10669601
Separate files:

index.html:
<a href="mypage1.php">click</a>
<a href="mypage2.php">click</a>

mypage1.php:
<?php
echo exec('/tmp/run/example1.sh');
?>

mypage2.php:
<?php
echo exec('/tmp/run/example2.sh');
?>
0
 

Author Comment

by:harryv
ID: 10670000
Hi,

I had that one as last option in mind but what I need is one page whitout opening new pages.
Just klik one a link or (better an image but text is also good) and that the script is running then.

Best regards,

Jeffeny
0
 
LVL 33

Accepted Solution

by:
snoyes_jw earned 125 total points
ID: 10670071
Use a frame or a separate window, and change the target of the link accordingly.

Alternatively, have the page submit to itself, something like this:

<?php
switch($_GET['link'])
{
    case 1: echo exec('/tmp/run/example1.sh');
    break;
    case 2: echo exec('/tmp/run/example2.sh');
    break;
}
// or, instead of a switch, you could use this if numbered correctly:
// if(is_set($_GET['link']))
// echo exec('/tmp/run/example' . $_GET['link'] . '.sh');
?>
<a href="thispage.php?link=1">Click</a>
<a href="thispage.php?link=2">Click</a>

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question