[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Condor-users] Batch Script Errors



You can't do a set inside a for loop using this syntax.   It's because of the way the for loop expands and
the way that interacts with %var% substitution.  All of the %var% substitutions happen _before_ the
for loop expands, so your code doesn't do what you think it does.

To get what you want you need to begin your batch script with

setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

then use ! rather than % for substitutions that should happen after the for loop expansion rather than
before it.

For more information about this, have a look a the output of

    help setlocal

and

    help set

Or you can rewrite your script so that it doesn't try to set a new value for filenum and outputName  inside the for loop.  Just use %%~nF%ftype% instead of %outputName% and the loop should work just fine.

-tj


On 7/18/2011 10:50 AM, Smith, Herb wrote:
Ben,

All execute nodes are XP (actually in this case for my development, there is only one node).  The echo commands that don't work are the last two:

@echo %fileNum%
@echo %outputName%

All I get is the response:  ECHO is OFF, rather than the actual variable value that I was after.  This works fine when I run the script at the command line.  The other ECHO commands correctly give the variable value.

I'm only transferring one input file with each executable, however, when I generate a Monte Carlo simulation I may have up to several hundred input files which will be numbered 0.in, 1.in, 2.in, ...etc.  The script will not know in advance which one it is running with at the time, so the loop was a device I was using to have the thing just look for whatever was there with a .in file type and to capture the particular file number.

Thanks,
Herb

-----Original Message-----
From: condor-users-bounces@xxxxxxxxxxx [mailto:condor-users-bounces@xxxxxxxxxxx] On Behalf Of Burnett, Ben
Sent: Friday, July 15, 2011 4:58 PM
To: Condor-Users Mail List
Subject: Re: [Condor-users] Batch Script Errors

Hi Herb:

Which of the echo command does not work?  Are all the execute nodes running XP? Also, there is no need for the loop if you are only transferring one of the input files with each job (unless that was unintentional).

-B

On 2011-07-15, at 1:22 PM, Smith, Herb wrote:

All,

I have a batch script that I want to use as my executable.  It runs fine when I run it manually from the command line.  When I have it submitted to the queue, it acts differently.  Two of the echo commands don't work and it says that one of my Rename commands is not correct (not the correct syntax).

Is there something I should be aware of when running a batch script as an executable?  I'm on Windows XP, Condor Ver. 7.6.1.

Here is the submit file:

Executable = CondorBat.bat
Universe   = vanilla
Output     = $(Process).msg
Error      = $(Process).err

should_transfer_files  =  YES
when_to_transfer_output = ON_EXIT


Transfer_input_files = hypt.exe, $(Process).in Transfer_output_files = 
$(Process).out

Log        = hypt.log

Queue

This is the batch script:

set ftype=.out
@echo %ftype%

for %%F in (*.in) do (
  @echo %%F
  @echo %%~nF
 set fileNum=%%~nF
 @echo %fileNum%
 set outputName=%fileNum%%ftype%
 @echo %outputName%
 ren %%F  "input.dat"

hypt.exe

ren output.dat %outputName%

)


Thanks in advance.

Herb


_______________________________________________
Condor-users mailing list
To unsubscribe, send a message to condor-users-request@xxxxxxxxxxx 
with a
subject: Unsubscribe
You can also unsubscribe by visiting
https://lists.cs.wisc.edu/mailman/listinfo/condor-users

The archives can be found at:
https://lists.cs.wisc.edu/archive/condor-users/
--
Ben Burnett
Optimization Research Group
Department of Math & Computer Science
University of Lethbridge
http://optimization.cs.uleth.ca

"Everyone is entitled to their opinion; you're not entitled to your own fact."
- Michael Specter



_______________________________________________
Condor-users mailing list
To unsubscribe, send a message to condor-users-request@xxxxxxxxxxx with a
subject: Unsubscribe
You can also unsubscribe by visiting
https://lists.cs.wisc.edu/mailman/listinfo/condor-users

The archives can be found at:
https://lists.cs.wisc.edu/archive/condor-users/
_______________________________________________
Condor-users mailing list
To unsubscribe, send a message to condor-users-request@xxxxxxxxxxx with a
subject: Unsubscribe
You can also unsubscribe by visiting
https://lists.cs.wisc.edu/mailman/listinfo/condor-users

The archives can be found at:
https://lists.cs.wisc.edu/archive/condor-users/