Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 453
  • Last Modified:

button or link that runs exec commands

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
harryv
Asked:
harryv
  • 2
1 Solution
 
snoyes_jwCommented:
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
 
harryvAuthor Commented:
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
 
snoyes_jwCommented:
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now