无法使用CFThread,CFExecute和Plink触发脚本

时间:2014-09-29 22:40:04

标签: batch-file coldfusion plink cfthread

我需要在网络上运行远程脚本来导入文件。如果我手动运行,我已经设置了plink并根据需要使用它。

  

plink name @ localserver -ssh -i myKey.ppk /home/here/scriptName.sh

我们正在ColdFusion中编写代码,因此这将使用CFExecute在CFThread中运行。 当我通过代码运行它时,cfexecute没有错误,它只是不会激活脚本。

在我的研究中,我发现人们说cfexecute在参数字符串中存在一些问题,更好的办法是创建批处理文件并使用cfexecute运行批处理文件。

所以我创建了一个批处理文件。     import.bat

C:\inetpub\wwwroot\myapp\plink\plink.exe name@localserver -ssh -i myKey.ppk /home/here/scriptName.sh)

如果我手动运行批处理文件,它会再次起作用。

  

import.bat

但如果我通过cfexecute运行它,它什么都不做。

为了测试cfexecute,我让它运行两个命令,第一个是我需要工作的,第二个是测试。第二个工作根据需要。第一个不是错误的屏幕或日志文件。如果我输入错误的语法就行了。第二个是根据需要写入文件。

(下面的代码)

                starting

                <cfoutput>

                <cfexecute name = "C:\inetpub\wwwroot\myapp\plink\import.bat"   errorfile="C:\inetpub\wwwroot\myapp\logs\#timeformat( now(),"HHMMSS") #.log"  ></cfexecute>

                <cfexecute name = "C:\WinNT\System32\netstat.exe"
                            arguments = "-e" 
                            outputFile = "C:\Temp\#timeformat( now(),"HHMMSS") #.txt"
                            timeout = "1">
                    </cfexecute>



                </cfoutput>
                the end
            <cfabort>

任何想法都会受到高度赞赏......

谢谢, 布赖恩

1 个答案:

答案 0 :(得分:1)

尝试

<cfexecute name="c:\winNt\system32\cmd.exe"
 arguments="/c C:\inetpub\wwwroot\myapp\plink\import.bat" timeout="100">
</cfexecute>