Can't fire script with CFThread, CFExecute and Plink

584 Views Asked by At

I am needing to run a remote script on our network to import files. I have set up plink and have it working as needed if I run it manually.

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

We are writing the code in ColdFusion so this will run in a CFThread using CFExecute. The cfexecute does not error when I run it via the code it just not fire the script.

In my research I have found people saying that cfexecute has some issues with the argument string and a better idea is creating a batch file and using cfexecute to run the batch file.

so I have created a batch file. import.bat

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

again if I run the the batch file manually it works.

import.bat

but if I run it via cfexecute it does nothing.

To test cfexecute I have it running two commands, the first what I need to work and the second a test. the second works as needed. the first one is not erroring to screen or log file. It did if I entered bad syntax. The second is writing to file as needed.

(code below)

                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>

any thoughts would be greatly appreciated...

Thanks, Brian

1

There are 1 best solutions below

4
Nebu On

Try

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