KBEC-00198 - Running an ec-perl script from Cygwin

Article ID:360032829932
1 minute readKnowledge base

To run an ec-perl standalone script from cygwin, these lines have to be added to your script

#!/bin/sh

exec "c:/Program Files/Electric Cloud/ElectricCommander/bin/ec-perl" -x "`cygpath -m "$0"`" "${@}"

#!perl

 #Rest of script…


Key Legend:

  • The 'exec' shell command says, "Replace this sh process with the execution of the following command, rather than spawning it as a child." This keeps the shell from running the rest of the script in its context after ec-perl completes.

  • -x says that when Perl runs, it should ignore everything before the #!perl line.

  • CloudBees CD (CloudBees Flow)'s perl is a win32 perl, so it won’t take unix-y paths for the script to run. Thus, we use "cygpath --m" to convert to Windows-style, '/' delimited (e.g. --m means "mixed" format).

  • $0 is the name of the script, as run on the shell (e.g. /tmp/ec.pl, ./ec.pl, ec.pl (for path lookup)).

  • "${@}" means all of the args from the command-line should be passed from this shell script (remember, this is an sh script to start with) to the program we’re 'exec’ing.

This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.