Home

Once upon a time things were easy:

This code grabs an XTension unit's property value "temp" that lives in unit "living"and puts it in a php variable:

$tempLiving=shell_exec("osascript -e 'tell application \"XTension\"' -e 'set MyValue to get unit property \"temp\" from unit \"living\"' -e 'end tell'");

This code grabs an XTension's unit value of unit "LivingHumidity" and puts it in a php variable:

$humidityLiving=shell_exec("osascript -e 'tell application \"XTension\"' -e 'set MyValue to value of \"LivingHumidity\"' -e 'end tell'");


Modern days however, make things more difficult: if you try this nowadays, you almost certainly will meet the error text

Symbol not found: __cg_jpeg_resync_to_restart
Referenced from:
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /Applications/MAMP/Library/lib/libJPEG.dylib

You can circumvent this by using the export DYLD_LIBRARY_PATH="" command first.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"

"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>

<title>Title</title>

<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />

<link rel="stylesheet" href="/css.css" type="text/css" />

</head>

<body>

<?php

$result=0;

$prep="#!/bin/sh"."\n".'export DYLD_LIBRARY_PATH=""'."\n";

//$command="osascript -e 'tell application \"XTension\"' -e 'set MyValue to value of \"livingtemp\"' -e 'return MyValue' -e 'end tell'";

$command=$prep."osascript -e 'tell application \"XTension\"' -e 'set MyValue to get unit property \"livingtemp\" from unit \"environment\"' -e 'return MyValue' -e 'end tell'";

echo $command;

$result=shell_exec($command);

echo "<br />"."the temperature is $result degrees";

?>


</body>

</html>

More information can be found in this topic on the MAMP Forum