我需要在网络上运行一个远程脚本来导入文件。我已经设置了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>
任何想法都是非常感激的..。
谢谢你,布莱恩
发布于 2014-10-01 14:45:43
试一试
<cfexecute name="c:\winNt\system32\cmd.exe"
arguments="/c C:\inetpub\wwwroot\myapp\plink\import.bat" timeout="100">
</cfexecute>
https://stackoverflow.com/questions/26110046
复制相似问题