-1

我需要在 python 上执行此操作任何帮助,此代码检查 xml 文件中的调制解调器状态,如果不正常则激活服务

XML 示例

<SMSCStatus>
        <Name>HUAWEI Mobile Connect - 3G Modem</Name>
        <Status>ERROR</Status>
        <StatusDetail>
                Modem Failure -- Unable to access modem, ensure that it is powered on and passes diagnostic tests.
        </StatusDetail>
        <MessagesToday>0</MessagesToday>
        <MessagesLast7Days>0</MessagesLast7Days>
        <MessagesLast30Days>0</MessagesLast30Days>
</SMSCStatus>
<?php

$xml = simplexml_load_file("xmlfile");
$status1 = $xml->SMSCStatus->Status;

if ($status1 == "OK")
        {
        $fp = fopen("status.txt", "w");
        fwrite($fp, "2");
        fclose($fp);
        }
  else
        {
        $statusr = json_encode(array(
                'server' => 'TOO FAIL'
        ));
        echo exec('net start "NowSMS"');
        }

?>
4

1 回答 1

1

在 python 中,将用作exec的替代模块simplexml_load_file子进程模块。

于 2013-02-08T05:51:34.493 回答