I have the following in a bat file :
#ECHO OFF
REM The following directory is for .NET 4.0
set DOTNETFX2=%SystemRoot%\Microsoft.NET\Framework\v4.0.30319
set PATH=%PATH%;%DOTNETFX2%
echo Installing IEPPAMS Win Service...
echo ---------------------------------------------------
C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil My.WindowsService.exe
echo ---------------------------------------------------
pause
echo Done.
The problem is that it even if the bat file is located in the same folder as the My.WindowsService.exe it will try to look for it in C:\Windows\System32.....
How do I solve this?
This is how it is solved :
#ECHO OFF
REM The following directory is for .NET 4.0
set DOTNETFX2=%SystemRoot%\Microsoft.NET\Framework\v4.0.30319
set PATH=%PATH%;%DOTNETFX2%
echo Installing IEPPAMS Win Service...
echo ---------------------------------------------------
C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil "%~dp0My.WindowsService.exe"
echo ---------------------------------------------------
pause
echo Done.
According to several articles I've found, passing an absolute path to your service is what you want. For example:
{...Path_To_.NET_Framework...}\InstallUtil C:\MyFolder\My.WindowsService.exe
You can grab your current directory with something like this in your batch file, if you want a dynamically generated path:
set CURDIR=%CD%
{...Path_To_.NET_Framework...}\InstallUtil %CURDIR%\My.WindowsService.exe
References:
How to Install Windows Service using command prompt
Install Windows Service
It is too old but was useful for me... I made some changes.
My service starts manually so, in the batch I included the start command and then open the console for checking the Installed Service.
#ECHO OFF
REM The following directory is for .NET 4.0
set DOTNETFX2=%SystemRoot%\Microsoft.NET\Framework\v4.0.30319
set PATH=%PATH%;%DOTNETFX2%
echo Installing MyService Win Service...
echo ---------------------------------------------------
C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil /i "%~dp0MyService.exe"
net start MyService
services.msc
echo ---------------------------------------------------
pause
echo Done.
Examples of install and uninstall
#ECHO OFF
REM The following directory is for .NET 4.0
set DOTNETFX2=%SystemRoot%\Microsoft.NET\Framework\v4.0.30319
set PATH=%PATH%;%DOTNETFX2%
echo Instalar Servicio......
echo ---------------------------------------------------
InstallUtil /i "%~dp0WindowsService1.exe"
echo ---------------------------------------------------
pause
echo Done.
#ECHO OFF
REM The following directory is for .NET 4.0
set DOTNETFX2=%SystemRoot%\Microsoft.NET\Framework\v4.0.30319
set PATH=%PATH%;%DOTNETFX2%
echo Desintalar Servicio...
echo ---------------------------------------------------
InstallUtil /u "%~dp0WindowsService1.exe"
echo ---------------------------------------------------
pause
echo Done.
Related
I have a working shell script that works with no problems but when I executed it with a run script i get the following error:
The script will scan all the proto files in a directory and convert it to Swift using ProtoBuf. After that I will move the swift files into an App folder. The script code is the following
#!/bin/bash
for protoFile in ./*.proto;
do
protoc --swift_out=. $protoFile
done
for file in ./*.swift;
do
mv $file ../Convert\ AV/Model/USBDongle/Proto/
done
Any ideas?
Thank you
I was calling the script from the directory it was located. When Xcode executes the the script that assumption is false. So I am getting the directory where the script is located and I do the logic with that path
#!/bin/bash
#Get Directory where the script is located
baseDirectory=$(dirname "$0")
echo "$baseDirectory"
for protoFile in "$baseDirectory"/*.proto
do
echo $protoFile
protoc --swift_out="$baseDirectory" -I "$baseDirectory" "$protoFile"
done
for protoFileSwift in "$baseDirectory"/*.swift;
do
echo $protoFile
mv "$protoFileSwift" "$baseDirectory"/../Convert\ AV/Model/USBDongle/Proto
done
* /* Makes like is a comment... *
I want to ask how to find all the executable names of a package in ROS (Robot Operating System)? For example, find spawn_model in gazebo_ros package. When I inspect the package in my system, it just shows some .xml, .cmake files, without any executables. But I can run it, such as: rosrun gazebo_ros spawn_model.
Thank you!
An easy way to do this is to type: "rosrun name_of_package " and then press tab two times, it should show you all the executables built.
After looking in the bash autocompletion script for rosrun, it looks like the command catkin_find is used to find the location of the executables for a package, and the executables are filtered with a find command.
If you want to create a script to give you a list of the executables follow the instructions below:
Save the following script in a file called rospack-list-executables:
#!/bin/bash
if [[ $# -lt 1 ]]; then
echo "usage: $(basename $0) <pkg_name>"
echo ""
echo " To get a list of all package names use the command"
echo " 'rospack list-names'"
exit
fi
pkgname=${1}
pkgdir="$(catkin_find --first-only --without-underlays --libexec ${pkgname})"
if [[ -n "${pkgdir}" ]]; then
find -L "${pkgdir}" -executable -type f ! -regex ".*/[.].*" ! -regex ".*${pkgdir}\/build\/.*" -print0 | tr '\000' '\n' | sed -e "s/.*\/\(.*\)/\1/g" | sort
else
echo "Cannot find executables for package '${pkgname}'." >&2
exit 1
fi
Then make the rospack-list-executables script executable (chmod +x rospack-list-executables) and place it in a directory that can be found in your $PATH environment variable.
Run the script:
$ rospack-list-executables gazebo_ros
debug
gazebo
gdbrun
gzclient
gzserver
libcommon.sh
perf
spawn_model
You should get the same result that you get when you type the rosrun <pkgname> command and press Tab:
$ rosrun gazebo_ros
debug gazebo gdbrun gzclient gzserver libcommon.sh perf spawn_model
You can check the executables for all packages with the following bash code:
rospack list-names | while read pkgname; do
echo "Executables for package '${pkgname}':";
rospack-list-executables $pkgname; echo "";
done
To enable package autocompletion for your newly created command, type the following:
complete -F _roscomplete rospack-list-executables
If you do not want to have to type the complete command every time you login, you can append it to your .bashrc file:
echo "complete -F _roscomplete rospack-list-executables" >> ~/.bashrc
Now when you type the command rospack-list-executables and press the Tab key, you should get a list of all the available packages to choose from.
catkin_find --first-only --without-underlays --libexec <your package name>)
should give you the folder where the executables are
I have installed the uncrustify through brew (as per the git instructions), and I have added the run script build phase to the xcode and tried to build an ios project, but the build is failing with the following error:
**/bin/sh: /Users/test/Library/Developer/Xcode/DerivedData/testProj- amlbymrfycxuzmemclwtovltjxzl/Build/Intermediates/testProj.build/Debug-iphoneos/testProj.build/Script-AC898878187BE0A00056CAB1.sh: sh: bad interpreter: No such file or directory**
How can I resolve this error? Any help would be appreciated. Thanks in advance.
My sh script:
if [ -n "$1" ]
then
# recover directory to format :
pathToSourcesDirectory=`echo $(pwd)/$1`
# go to current folder :
scriptDirectory=$(dirname $0)
cd $scriptDirectory
# find sources files to format :
echo ""
echo "==> Getting files to format in directory " + $pathToSourcesDirectory
mkdir -p temp
find $pathToSourcesDirectory -name "*.[mh]" > temp/sources_to_uncrustify.txt
# format files :
echo ""
echo "==> Format files"
/usr/local/bin/uncrustify -F temp/sources_to_uncrustify.txt -c "../uncrustify_objective_c.cfg" --no-backup
# remove temp files :
rm -rf temp/
else
echo "Error : You must specify a source folder as first parameter"
fi
It looks like you don't have Shell set to /bin/sh in the Xcode Run Script configuration:
(screenshot taken from here).
I am looking for functionality where we have a directory with some files in it.
Whenever any one makes a change in any of the files in the directory, jenkins shoukd trigger a build.
Is there any plugin or mathod for this functionality. Please advise.
Thanks in advance.
I have not tried it myself, but The FSTrigger plugin seems to do what you want:
FSTrigger provides polling mechanisms to monitor a file system and
trigger a build if a file or a set of files have changed.
If you can monitor the directory with a script, you can trigger the build with a HTTP GET, for example with wget or curl:
wget -O- $JENKINS_URL/job/JOBNAME/build
Although slightly related.. it seems like this issue was about monitoring static files on system.. however there are many version control systems for just this purpose.
I answered this in another post if you're using git to track changes on the files themselves:
#!/bin/bash
set -e
job_name="whatever"
JOB_URL="http://myserver:8080/job/${job_name}/"
FILTER_PATH="path/to/folder/to/monitor"
python_func="import json, sys
obj = json.loads(sys.stdin.read())
ch_list = obj['changeSet']['items']
_list = [ j['affectedPaths'] for j in ch_list ]
for outer in _list:
for inner in outer:
print inner
"
_affected_files=`curl --silent ${JOB_URL}${BUILD_NUMBER}'/api/json' | python -c "$python_func"`
if [ -z "`echo \"$_affected_files\" | grep \"${FILTER_PATH}\"`" ]; then
echo "[INFO] no changes detected in ${FILTER_PATH}"
exit 0
else
echo "[INFO] changed files detected: "
for a_file in `echo "$_affected_files" | grep "${FILTER_PATH}"`; do
echo " $a_file"
done;
fi;
You can add the check directly to the top of the job's exec shell, and it will exit 0 if no changes detected.. Hence, you can always poll the top level of the repo for check-in's to trigger a build. And only complete a build if the files in question change.
Now I am compiling my MetaTrader .mq4 files to .ex4 files with MetaEditor.
But my .mq4 files are generated by a Java-process, and I would like to automate the compilation process.
Is there a command-line compiler tool I could call programmatically?
To compile a source code file from a command line, you can use MetaEditor for that. For example:
metaeditor.exe /compile:"C:\Program Files\Platform\MQL5\Scripts\myscript.mq5"
For 64-bit use metaeditor64.exe instead.
In Linux/macOS, this can be achieved using Wine, e.g.:
wine metaeditor.exe /compile:"MQL4/Experts/MACD Sample.mq4"
For mass compilation, you can specify folder, like:
metaeditor.exe" /compile:"MQL5\Scripts"
To specify custom MQL5/MQL4 folder with include files, you can use /inc parameter, for example:
metaeditor.exe /compile:"./Scripts" /inc:"C:\Program Files\TradingPlatform 2\MQL5"
For additional information about the compilation process, you can use /log:
metaeditor.exe /compile:"C:\Program Files\Platform\MQL5\Scripts\myscript.mq5" /log
To check for the syntax only, add extra /s.
If the compilation fails, the MQL4.log file would be created in the platform folder with the relevant details. It's going to be in UTF-16 format, so you may need a special tool for it (such as Vim, Ruby, findstr or rg).
To specify the custom compilation log file, use /log:file.log parameter, e.g.
metaeditor.exe /log:errors.log /compile:.
Note: Display to the standard output is not supported (although on Linux you can use: /log:CON).
For more information, check: Compilation from the Command Line
Some time ago you could download the compiler of MQL4/MQL5 programs that runs separately from MetaEditor — MQL.exe. It was distributed separately from the terminal and you could download it at the following addresses:
https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mql.exe
https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mql64.exe
Usage (as per MQL4/MQL5 Compiler build 1162 from 02 Jul 2015):
mql.exe [<flags>] filename.mq5
/mql5 - compile mql5 source
/mql4 - compile mql4 source
/s - syntax check only
/i:<path> - set working directory
/o - use code optimizer
However the standalone compiler was intentionally removed, so now links point to the installer in favor of MetaEditor.
Much older version of MetaTrader prior to build 600 had metalang.exe included with the platform.
However in build 616, MetaQuotes intentionally has removed the compiler (mql.exe/mql64.exe) from the standard MetaTrader installation.
This means if you upgrade your MT platform (>616), the compiler executable will be removed.
This is a little late, but since I wrote a little script for UltraEdit/UEStudio and have received heaps of help from stackoverflow, here is my script. It compiles then copies the ex4 to a number of test MT4 installations:
The "Compile" button on UE does:
"MT4Compile.bat" "%FilePath" "%FileName"
Start in path eg: D:\Development\MQ4 (Location of MT4Compile.bat)
Normally my source code is in a library tree under D:\Development\MQ4[Group][ExpertName][FileName].mq4
Contents of D:\Development\MQ4\MT4Compile.bat:
#echo off
rem Version: 1.1
rem Date: 24 Sep 2013
rem Author: Shawky
rem Refer to HELP: for info
SET XC=xcopy /D /Y /V /F /I
SET PROGDIR=D:\Development\Go Pro Demo (MQ4 Testing)
SET DSTPATH=%PROGDIR%\experts
SET SIMPATH1=G:\Apps\MT4\BackTest IC (Recent)\experts
SET SIMPATH2=G:\Apps\MT4\BackTest IC (All)\experts
SET SIMPATH3=G:\Apps\MT4\BackTest Go (All)\experts
SET DEPLOYPATH=D:\Development\Deployment\experts
SET SRCPATH=%1
SET SRCPATH=%SRCPATH:"=%
IF "%SRCPATH%"=="" (
SET SRCPATH=[Arg1]
)
SET APPNAME=%2
SET APPNAME=%APPNAME:"=%
IF "%APPNAME%"=="" (
SET APPNAME=[Arg2]
)
SET SRCFILE=%APPNAME%.mq4
SET DSTFILE=%APPNAME%.ex4
SET CMD="%PROGDIR%\metalang.exe" "%SRCFILE%" "%DSTFILE%"
IF "%SRCPATH%"=="[Arg1]" GOTO HELP
IF "%APPNAME%"=="[Arg2]" GOTO HELP
cd %SRCPATH%
IF NOT EXIST "%SRCFILE%" (
SET ERROR=Error: File "%SRCFILE%" does not exist in %SRCPATH%
GOTO HELP
)
echo .
echo Compiling %SRCFILE% to %DSTPATH%\%DSTFILE%
echo .
DEL *.log
%CMD%
IF EXIST "%DSTFILE%" (
echo .
echo Distributing executable to SIM and Deployment paths
%XC% "%DSTFILE%" "%DSTPATH%\"
IF EXIST "%SIMPATH1%" %XC% "%DSTFILE%" "%SIMPATH1%\"
IF EXIST "%SIMPATH2%" %XC% "%DSTFILE%" "%SIMPATH2%\"
IF EXIST "%SIMPATH3%" %XC% "%DSTFILE%" "%SIMPATH3%\"
IF EXIST "%DEPLOYPATH%" copy /B /Y "%DSTFILE%" "%DEPLOYPATH%\%APPNAME% (Dev).ex4"
)
goto END
:HELP
echo . Metatrader 4 Command Line utility for compiling MT4 programmes.
echo .
echo . This batch files allows MT4 applications to be compiled from a directory other than .\experts.
echo . The output will be copied to experts after compilation.
echo .
echo . [Arg1] = Path to MT4 application directory
echo . [Arg2] = Name (without extension) of the main MQ4 source code to compile.
echo .
echo . Example:
echo . MT4Compile.bat "D:\Development\MQ4\MyExpert\" "PrimaryMQ4FileName"
echo .
echo . Programme Directory: %PROGDIR%
echo . Source Path: %SRCPATH%
echo . Source File: %SRCFILE%
echo . Destination File: %DSTFILE%
echo . Target Path: %DSTPATH%
echo .
echo . Argument 1: %SRCPATH%
echo . Argument 2: %APPNAME%
echo .
echo . Commands to execute would be:
echo .
echo . %CMD%
echo . %XC% "%DSTFILE%" "%DSTPATH%\"
echo .
echo . %ERROR%
echo .
pause
:END
All the best.
Shawky
Yes, there is an executable in the install directory of the terminal. It is called metalang.exe.