Answer the question
In order to leave comments, you need to log in
PHP: Running multiple shell commands?
There is a task to take screenshots of web pages, for this I use the CutyCapt console utility, since an x-server is needed for its operation, I launch it through a fake xvfb, for example:
xvfb-run --server-args="-screen 0, 1024x768x24" ./CutyCapt --url=... --out=...
xvfb-run --server-args="-screen 0, 1024x768x24" ./CutyCapt --url=... --out=... && ./CutyCapt --url=... --out=... && ./CutyCapt --url=... --out=...
Answer the question
In order to leave comments, you need to log in
<?php
if(isset($_POST['urls'])) {
$urls = explode("\n", trim((string)$_POST['urls']));
$sh = time() % rand(1000,9999) * rand(10,99); $sh .= '.sh';
$f = fopen($sh, 'w');
foreach($urls as $k=>$v) {
fwrite($f, '/usr/bin/cutycapt --url='.trim($v).' --out=img'.$k.'.png'."\n");
}
fclose($f);
system('/usr/bin/xvfb-run --server-args="-screen 0, 1024x768x24" /bin/bash '.$sh);
foreach($urls as $k=>$v) {
echo '<img src="img'.$k.'.png">
';
}
}
?>
<form action="capt.php" method="POST">
<textarea name="urls"></textarea>
<input type="submit">
</form>
Try like this:
bash -c 'xvfb-run --server-args="-screen 0, 1024x768x24" ./CutyCapt --url=... --out=... && ./CutyCapt --url=... --out=... && ./CutyCapt --url=... --out=...'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question