Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Currently, I would like to call Tool Command Language Scripts that is located in server A.

When a user surf a website that is hosted in server B. When, a user click on a button for example, I would like the php file to execute the Tcl scripts that is located in server B.

How do I do that?

Thank you in advance.

share|improve this question

1 Answer 1

Use a PHP execution operator (note that you should be extremely careful - if possible, limit to valid scripts instead of letting the user specify arbitrary commands in a GET or POST variable).

Example:

http://myserver.com/php_scriptname.php?tcl_call=asdf.tcl

<?php

if ( !file_exists("/path/to/tclsh") ) {
  die('unable to access TCL interpreter - check user permissions for UID ' . getmyuid() );
}

switch ( $_GET['tcl_call'] ) {

  case 'asdf.tcl':
    `/path/to/tclsh /path/to/asdf.tcl`
  break;

  default:
    die('invalid script called');
  break;

}

?>

Edit:

Your question presently reads:

When a user surf a website that is hosted in server B. When, a user click on a button for example, I would like the php file to execute the Tcl scripts that is located in server B.

... but if you wanted to call a script on server "A", you could set up an SSH key and then call SSH from your script on server "B" - for example:

  case 'asdf.tcl':
    `ssh phpuser@servera '/servera/path/to/tclsh /servera/path/to/asdf.tcl'`
  break;

(Single quotes and backticks)

Note that you can store what is returned from the execution operator in a variable or echo it - you may want to echo the return value and include 2>&1 at the end of every command you run for debugging.

share|improve this answer
    
wow! that was pretty a good explaination. I will try this method and update you soon. Thanks again! :D –  Syahmul Aziz Oct 29 '10 at 6:23
    
for ssh method, don't we need to specify the password in the script? –  Syahmul Aziz Oct 31 '10 at 14:17
    
You should set up a limited user account for your script and use an SSH key - see link from answer: pkeck.myweb.uga.edu/ssh –  danlefree Nov 1 '10 at 8:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.