我有一个复杂的场景。这是场景。
我有一个shell脚本,用于检查shell脚本中的许可证
#!/bin/bash
macid="00:e0:4c:36:20:43"
/usr/bin/curl -o /tmp/.chk -d "mac_id=$macid" http://www.example.com/licensecheck.php
在example.com/licensecheckfile.php中包含许可证检查的代码
这是我的licensecheck.php文件是
<?php
// here is code to check macid in database and return status whether it is **expired**,**running**, or **not register**
include './download.php';
?>
和download.php文件是
<?php
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename('file.sh'));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize('file.sh'));
readfile('http://example/test.txt');
exit;
?>
所以这可以将文件下载为file.sh,但正如我告诉该文件是从shell脚本调用的那样,它在/tmp/.chk中显示输出如下输出
registered#!/bin/bash
echo "### STARTED AT | `date +'%Y-%m-%d %H:%M'`"
但我需要file.sh作为新文件,而/tmp/.chk应该包含已注册的文件.sh应该包含
#!/bin/bash
echo "### STARTED AT | `date +'%Y-%m-%d %H:%M'`"