Solved

button or link that runs exec commands

Posted on 2004-03-24
3
447 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article discusses how to create an extensible mechanism for linked drop downs.
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…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

710 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