It turns out my FTP client smushed my shell script, so thanks to everyone who contributed. :)
===============================
I'm trying to use PHP to execute a shell script stored in the same directory as my PHP script using exec()
, but I get an error:
sh: 1: ./hlsvod.sh: not found
I've tried using the full path to the script, I've chmodded it 777, I've tried using shell_exec()
but I still get the same error (I redirected the stderr
to stdout
to get it). The script definitely exists. Could you help?
Code:
<?php
/* Probably not the most elegant solution but it works. */
$pid = $_GET['pid'];
if(empty($_GET['pid'])){
die("No PID -- do ?pid=XXXXXXXX");
}
$tmpfile = exec("./hlsvod.sh ".$pid." 2>&1");
echo nl2br(shell_exec("pwd;whoami;"));
var_dump($tmpfile);
$a = fopen($tmpfile."m3u8", "r");
$stream = fread($a);
fclose($a);
$b = fopen($tmpfile."subs");
$subs = fread($b);
fclose($b);
var_dump($stream);
var_dump($subs);
?><!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width,user-scalable=no">
<title>New 3DS iPlayer - <?=$pid;?></title>
</head>
<body>
<h1>Live HLS Stream for <?=$pid;?></h1>
<p>HLS stream URL: <a href="<?=$stream;?>"><?=$stream;?></a></p>
<p>VTT subtitles URL: <a href="<?=$subs;?>"><?=$subs;?></a></p>
<video id="video" controls preload="metadata">
<source src="<?php echo $stream; ?>">
<track label="English" kind="subtitles" srclang="en" src="<?=$subs;?>" default>
</video>
</body>
</html>