• Welcome to Valhalla Legends Archive.
 

How to open programs

Started by Kaiory, July 28, 2004, 11:54 PM

Previous topic - Next topic

Kaiory

Is it possible to open and or close a program through a certain weblanguage?

Maddox

#1
system(), exec(), and passthru() in PHP, I'm not sure about other languages.
asdf.

Kaiory


MeltingWax


Banana fanna fo fanna

I have a similar question to this...in PHP...how can you start a process with certain environment variables?

Adron

Quote from: $t0rm on August 08, 2004, 10:49 AM
I have a similar question to this...in PHP...how can you start a process with certain environment variables?

A post on a page at the php site says:

Quote
nehle at dragonball-se dot com
21-Oct-2003 11:59
Remember that some shell commands in *NIX needs you to set a TERM enviroment. For example:
<?php
exec('top n 1 b i', $top, $error );
echo nl2br(implode("\n",$top));
if ($error){
  exec('/usr/bin/top n 1 b 2>&1', $error );
  echo "Error: ";
  exit($error[0]);
}
?>
This will echo "Error: TERM enviroment variable not set. " To fix it, add  TERM=xterm (Or some other terminal) to the exec-statement, like this

<?php
exec('TERM=xterm /usr/bin/top n 1 b i', $top, $error );
echo nl2br(implode("\n",$top));
if ($error){
  exec('TERM=xterm /usr/bin/top n 1 b 2>&1', $error );
  echo "Error: ";
  exit($error[0]);
}
?>