Vem har bajsat i min termos?
Köra .bat-fil remote?
Visa signatur
Visa signatur
Backend programmerare för webbutvecklarna i malmö, slänga iväg ett PM om du har någon PHP-relaterad fråga.
Tänkte köra en websida på en apacheserver. Websidan har en appikation som kör .bat-filer. Hur styr jag applikationen från en annan dator? Alltså, applikationen exekverar enbart -bat-filen på servern. Går det?
Vem har bajsat i min termos?
Kör du php till apache kan du använda dig av funktionen exec(), se till att säkra koden bara så inte användarna får möjlighet att exekvera egna kommadon.
Läs mer om funktionen på php.net: http://se2.php.net/manual/en/function.exec.php
Backend programmerare för webbutvecklarna i malmö, slänga iväg ett PM om du har någon PHP-relaterad fråga.
Den här koden kör en batchfil och sedan skickar den ut alla rader.
test.php
<html>
<head>
<title>Test</title>
</head>
<body>
<?php
echo "<b>test.bat:";
$test = array();
exec('test.bat', $test);
$execute = count($test);
echo "<br /><blockquote>";
for($v = 0; $v < count($test); $v++) {
echo $test[$v];
echo "<br />";
}
echo "</blockquote></b><br />Done!";
?>
</body>
</html>
test.bat
@echo off
echo 45rt8ejsdhsdhsdfdsmf
echo 45rt8ejhsdhsdfdsmfgasdzgb
echo 45rt8ejfdxgbxchdshsdsmf
echo 45rt8ejsdhsdhfdsmfshshsd
echo 45rt8ejfddshsdhsdhsdmf
echo sdh45rt8ejfdsmf
echo h5rt8edshsdhdhdsjfdsmf
echo 45rt8edhdshsdhshf
echo 45rt8ejfddshsmfhsdh
echo 45rt8ejsdhshshsfdsmf
echo 45rt8ejhsdhsdhsdfdsmf
echo 45rt8ejfhsdhdshdsmfshh
echo 45rt8ejfhdshsdhsdhdsmf
Copyright © 1999–2023 Geeks AB. Allt innehåll tillhör Geeks AB.
Citering är tillåten om källan anges.