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

Re: [Condor-users] heterogeneous submission of an executable

I know it doesn't solve your current problem, but Condor 7.7.4 and later sets OpSys="WINDOWS" for all windows machines
so this won't actually be a long term problem for you. 

It might be easier in the mean time to solve this problem by having a single Run_program.bat file that works
on both Windows and Linux.   If you have perl everywhere, you can call it Run_program.pl  and it will work
everywhere because LINUX looks at the first line of the file for the #!  and windows looks at the file extension.

The other thing that works everywhere is something I call the shabang hack.   It works like this
  • create a small windows  console application that returns 0, name it "#!.exe"
  • send #!.exe along with your job
  • use Run_anywhere.bat as your executable, it should start with the usual Linux #!

#!&& @goto windows_part

echo 'Linux'
ls -l

exit 0
@echo off

@echo Windows

----end of Run_anywhere.bat----

On Linux this works as a normal bash script, the exit 0 stop it before it gets to the the windows_part
What Windows sees is a .bat file, so it runs in the command shell.   the first line is #!/bin/bash
Windows sees that as "Run the program #!.exe and pass it /bin/bash as arguments." 
The second line is #!&& @goto windows_part,
Windows sees that as "Run the program #! and if it succeeds goto the windows_part label in this script"

So you have one script, that contains both Linux and Windows commands.
It works on windows as long as you program named #!.exe in the current directory (or in the path) that returns success.

Here's the source to a c program that can be your #!.exe.

---- success.cpp ---
// Force the linker to include KERNEL32.LIB
#pragma comment(linker, "/defaultlib:kernel32.lib")
extern "C" void __stdcall ExitProcess(unsigned int uExitCode);
extern "C" void __cdecl begin( void ) { ExitProcess(0); }

---- end of success.cpp

You compile it using the Microsoft C++ compiler like this
    cl success.cpp /link /subsystem:console /entry:begin kernel32.lib


On 2/16/2012 10:03 AM, Tiago Macarios wrote:

I saw in the manual that I could do heterogeneous submission of files using:
A common use of this macro is for the heterogeneous submission of an executable:
executable = povray.$$(opsys).$$(arch)

The problem is that my pool is mostly windows but highly heterogeneous and my scripts are all the same. Is there a easy way to address all machine (sort of a WinAll?). I tried some variations of the code below but I always get an error.

OpSysWindows = (OpSys=="WINNT50"|| OpSys=="WINNT51"|| OpSys=="WINNT52"|| OpSys=="WINNT61")
OpSysLinux = (OpSys=="LINUX")
ExecutableName = ifThenElse($(OpSysWindows), "OnWindows", "OnLinux" )

Universe = vanilla
requirements = (Arch=="x86"|| Arch=="x86_64") && ($(OpSysWindows)|| $(OpSysLinux)) && Memory>=2000
Executable = Run_$$(ExecutableName).bat


T. Mac.

Condor-users mailing list
To unsubscribe, send a message to condor-users-request@xxxxxxxxxxx with a
subject: Unsubscribe
You can also unsubscribe by visiting

The archives can be found at: