2012-09-21 59 views
0

我正在使用shell命令将文档文件转换为pdf。每个用户可以随时将其文件转换为PHP。有多个用户可以同时访问我的转换器来转换他们的文件吗?多次访问shell脚本

我在专用服务器上使用CENTOS。

回答

1

让我们来定义你的php转换工具的可能层次。

terminal # user enters commands here, sees output 

     shell # the terminal automatically starts a shell process 
      # so users can type commands and get work done 

      /path/to/your/conversion/tool.php doc1.doc doc1.pdf 
      # here is the user, accessing your script. 
      # one solution to conversions is to allow for 1 input and 1 ouput file 
      # I have done that to keep things simple, your solution may be different 

      phpcode shell("externalconverter", "doc1.doc","doc1.pdf", "/path/to/tmpWrkSpace"?)     
      # again, a guess, your php is asking to execute a external command 
      # and we're passing the arguments 

        "externalconverter" "doc1.doc" "doc1.pdf" tmp="/path/to/tmpWrkSpace" 
        # again, a guess 

所以,这取决于你或exteranlconverter创建静态的(或者非唯一的)名称的临时文件。 也就是说2个用户使用不同的文件名同时启动程序,是否创建了具有完全相同名称的临时文件?可能不会,但是这种事情发生并且值得提前检查。

为了确认您的安全,请使用2个终端窗口设置测试,提前输入两个命令,使用专门为此测试创建的.doc文件并且无关紧要,同时执行两个命令时间(尽可能快)。你需要一个足够大的文件(或者在任何情况下)来花费很长时间来处理你确定两个文件正在被同时处理。

通常,假设Linux/Unix操作系统,大多数程序允许同时运行多个副本。但测试是你最好的防守。

如果这不能回答您的问题,请考虑使用上述提纲编辑您的问题,向我们展示转换工具中元素的层次结构。 IHD。

IHTH。

+0

+1非常好的方法来模糊的问题。 – chepner