cfexecute issue with batch file

642 views
Skip to first unread message

D L

unread,
Nov 7, 2009, 11:15:10 AM11/7/09
to ra...@googlegroups.com
Hi,

I'm on Railo 3.1.1.006 for Windows.

The following code runs without error, that is, the success var's value is false positive, the task has been performed.
<cfparam name="success" default=1>
<cftry>
<cfexecute name="C:\myApp\backupFile.bat"/>
<cfcatch type="any"><cfset success = 0></cfcatch>
</cftry>

The batch file runs fine by itself.

Any idea what's going on?  Or have I not really waken up yet this morning?

Thanks.

Paul Kukiel

unread,
Nov 7, 2009, 11:22:32 AM11/7/09
to ra...@googlegroups.com
Are you sure its executing?

Take out the try/catch see what happens.

Paul.

D L

unread,
Nov 7, 2009, 11:26:44 AM11/7/09
to ra...@googlegroups.com
ok, Kolbenschlag, Clemens's thread on cfexecute has shed some light to the issue.

However, after making changes on how to call a program on the computer accordingly, that is,
<cfexecute name="cmd.exe" arguments="/c C:\Program Files\Railo\webapps\ROOT\myapp\backupFile.bat"/>

It's still false positive.

even an attempt to circumvent the white space in the Program File folder like this
<cfexecute name="cmd.exe" arguments="/c 'C:\Program Files\Railo\webapps\ROOT\myapp\backupFile.bat'"/>

does not help.  hmmm... what's wrong?  thanks.


Kolbenschlag, Clemens

 to railo

D L

unread,
Nov 7, 2009, 11:31:15 AM11/7/09
to ra...@googlegroups.com
Good idea.  Still,
either
<cfexecute name="cmd.exe" arguments="/c C:\Program Files\Railo\webapps\ROOT\
myapp\backupFile.bat"/>

or


<cfexecute name="cmd.exe" arguments="/c 'C:\Program Files\Railo\webapps\ROOT\
myapp\backupFile.bat'"/>

produced nothing.  Totally blank.

Paul Kukiel

unread,
Nov 7, 2009, 11:59:05 AM11/7/09
to ra...@googlegroups.com
Is the back up script running?  ie are the files in your batch file actually being copied/backed up?

Paul.

D L

unread,
Nov 7, 2009, 12:07:26 PM11/7/09
to ra...@googlegroups.com
Yes, as I mentioned, the back up batch script runs/executes fine when it runs by itself NOT with Railo.  But with Railo's cfexecute, it does not.

D L

unread,
Nov 7, 2009, 12:08:31 PM11/7/09
to ra...@googlegroups.com
Also, I was testing with an XP box, am concerned with Vista it could be worse with the extra security stuff...

Ryan Letulle

unread,
Nov 7, 2009, 12:09:58 PM11/7/09
to ra...@googlegroups.com
When you run it in windows you are an administrator.  Check the logs to see if it is a security issue.
 
--
Ryan LeTulle

Chris Blackwell

unread,
Nov 7, 2009, 3:21:22 PM11/7/09
to ra...@googlegroups.com
try adding the timeout attribute to cfexecute and give it a few seconds to execute


2009/11/7 D L <tatat...@gmail.com>

Paul Kukiel

unread,
Nov 7, 2009, 4:08:10 PM11/7/09
to ra...@googlegroups.com
Is the .bat file doing stuff that the user Railo is running as has permission to?  ie accessing a network drive or unc path?

Paul.

D L

unread,
Nov 7, 2009, 6:38:31 PM11/7/09
to ra...@googlegroups.com
Interesting thought.  And yet still to no avail.

Currently the code looks like this
<cfexecute name="cmd.exe" arguments="/c C:\backupfiles.bat" timeout="35" />

What the backfiles.bat does is to copy directory and files from C drive to a flash drive,
the batch file uses for /f loop and special characters like && etc., pretty standard for a batch file... could it be possible that Rail don't "like" them?

Thanks.

D L

unread,
Nov 7, 2009, 6:40:20 PM11/7/09
to ra...@googlegroups.com
Railo is running under Local System and the batch file simply does some local directory and its files copying...

Sean Corfield

unread,
Nov 7, 2009, 6:57:52 PM11/7/09
to ra...@googlegroups.com
I guess the next question is: can you successfully execute *any* batch
files from Railo?

Perhaps you can create some very simple batch file that does one
minimal operation that you can inspect for success and then try
running that from a CFML page?

D L

unread,
Nov 7, 2009, 7:56:44 PM11/7/09
to ra...@googlegroups.com
<cfexecute name="cmd.exe" arguments="/c dir" variable="listDir" timeout="20" />
failed.
err msg:
timeout [20000 ms] expired while executing [cmd.exe /c dir]

<cfexecute name="cmd.exe" arguments="/c dir" timeout="20" />
shared same fate.

and so did
<cfexecute name="cmd.exe" arguments="dir" timeout="20" />

Why would railo cfexecute fail such a simple task?  I'm puzzled.  The user account logged into the xp box has adm privilege as well...

Calrain

unread,
Nov 7, 2009, 10:10:27 PM11/7/09
to Railo
Hmm.. I replied 3 times to this response and it isn't posting.

If somehow 3 entries appear, I apologise.

I must have had some invalid characters in the message.

I got it working.

The problem is that Railo needs backslashes escaped, so \ becomes \\

This modified version of your original example works on my
installation:
<cfparam name="success" default=1>
<cftry>
<cfexecute name="C:\\myApp\\backupFile.bat" variable="backupoutput"/>
<cfcatch type="any"><cfset success = 0></cfcatch>
</cftry>
success = <cfoutput>#success#</cfoutput><br>
backupoutput = <cfoutput>#backupoutput#</cfoutput><br>

In my version of backupFile.bat, the contents are:
@echo off
Echo Backup Complete


I discussed more in my original post, about stdout and errout, and how
to manage that... Remember to put single quotes around any file names
or file paths that have spaces, especially in the arguments field.

Cheers,

On Nov 8, 10:56 am, D L <tatata9...@gmail.com> wrote:
> <cfexecute name="cmd.exe" arguments="/c dir" variable="listDir" timeout="20"
> />
> failed.
> err msg:
> timeout [20000 ms] expired while executing [cmd.exe /c dir]
>
> <cfexecute name="cmd.exe" arguments="/c dir" timeout="20" />
> shared same fate.
>
> and so did
> <cfexecute name="cmd.exe" arguments="dir" timeout="20" />
>
> Why would railo cfexecute fail such a simple task?  I'm puzzled.  The user
> account logged into the xp box has adm privilege as well...
>
> On Sat, Nov 7, 2009 at 6:57 PM, Sean Corfield <seancorfi...@gmail.com>wrote:
>
>
>
>
>
> > I guess the next question is: can you successfully execute *any* batch
> > files from Railo?
>
> > Perhaps you can create some very simple batch file that does one
> > minimal operation that you can inspect for success and then try
> > running that from a CFML page?
>

Calrain

unread,
Nov 7, 2009, 9:22:23 PM11/7/09
to Railo
I got it working.

The problem is that Railo needs backslashes escaped, so \ becomes \\

This modified version of your original example works on my
installation:
<cfparam name="success" default=1>
<cftry>
<cfexecute name="C:\\myApp\\backupFile.bat" variable="backupoutput"/>
<cfcatch type="any"><cfset success = 0></cfcatch>
</cftry>
success = <cfoutput>#success#</cfoutput><br>
backupoutput = <cfoutput>#backupoutput#</cfoutput><br>

In my version of backupFile.bat, the contents are:
@echo off
Echo Backup Complete

Command Line tools have two main output streams, Standard Output
(stdout) and Error Output (errout).

After looking at Ben Forta's site, he states that cfexecute only
captures stdout, which is the case in Railo as well.

But if you have errout, it can be redirected to stdout within a batch
file, here is an example of a modified backupFile.bat which redirects
errout (2) to stdout (1):
@echo off
echo Backup Complete
echo Error Out 2>&1

That works in Railo too, you will see both lines echo out.


There seems to be an issue with Railo with spaces in the cfexecute
arguments attribute, here is a link:
http://www.photoswarm.com/blog/?p=204

I think it is only important if spaces exist in the path of a file
name in the argument.

"/c c:\\myfile.txt" seems to be ok, but "/c c:\\my file.txt" is not
ok.

That can be fixed if you call cfexecute like this:
<cfexecute
name="C:\\WINDOWS\\system32\\cmd.exe"
arguments="/c 'C:\\myApp\\backup File.bat'"
variable="myoutput"
timeout="15"/>

there you see that around the c:\\myApp\\backup File.bat there are
single quotes in there, that fixes the space problem in the file name.

Hope that helps.

Cheers,

David Thomas

unread,
Nov 7, 2009, 8:41:07 PM11/7/09
to ra...@googlegroups.com
I got it working.

The problem is that Railo needs backslashes escaped, so \ becomes \\

This modified version of your original example works on my installation:
<cfparam name="success" default=1>
<cftry>
<cfexecute name="C:\\myApp\\backupFile.bat" variable="backupoutput"/>
<cfcatch type="any"><cfset success = 0></cfcatch>
</cftry>

David Thomas

unread,
Nov 7, 2009, 7:18:19 PM11/7/09
to ra...@googlegroups.com
If you are copying files under the SYSTEM account, then that account only has access to files on that named machine.

If you want to access shares on other machines, then you must grant the Computer Account access to those shares, as the Computer Account is the security entity used by SYSTEM when it tries to access things across the network.

...just in case that was what you were trying to do.

Cheers

D L

unread,
Nov 7, 2009, 11:07:10 PM11/7/09
to ra...@googlegroups.com
My copy of Railo is running under Local System.

Dave

unread,
Nov 8, 2009, 3:00:16 AM11/8/09
to ra...@googlegroups.com
why don't you just run a scheduled task to use cf to zip the folder and then move it, would be a lot easier.

Michael Offner-Streit

unread,
Nov 8, 2009, 8:15:12 AM11/8/09
to ra...@googlegroups.com
we have solved this isue for next release

see ticket
https://jira.jboss.org/jira/browse/RAILO-489

greetings micha

D L schrieb:
Reply all
Reply to author
Forward
0 new messages