I am trying to run python script with arguments using WinAPI function ShellExecuteW.
It looks like a
python .\PythonDLL_Example.py 125960 126110 126070 126250 3928 274353.845945816 119761.8349277858 18080.59072693367 -252416.3714632094 -79682.09253258759 -12446.11663140202
I tried to do like this using full paths, just in case:
ShellExecuteW(NULL, NULL, "C:\\Users\\Amber\\AppData\\Local\\Programs\\Python\\Python37\\python.exe", "C:\\Users\\Amber\\AppData\\Roaming\\MetaQuotes\\Terminal\\DEA332DEFF5165CB2EAFB6F9BD062C50\\MQL5\\Experts\\Advisors\\PythonDLL_Example.py 125960 126110 126070 126250 3928 274353.845945816 119761.8349277858 18080.59072693367 -252416.3714632094 -79682.09253258759 -12446.11663140202", NULL, 10);
No result
Error %d42
Test execution like below run successfully:
ShellExecuteW(NULL, "open", "C:\\Windows\\Notepad.exe", NULL, NULL, 10);
Please, ho to execute my script?
Thank you
How I solved my case:
I associated .py files with python.exe in my OS Windows. So, I do not use "python .\PythonDLL_Example.py ....." I use ".\PythonDLL_Example.py ....." instead.
I sorted out, that "%d42" is not an error. This is HINSTANCE of process. I found a mistake of my script (no transmitted arguments to script).
for me, correct is:
ShellExecuteW(NULL, NULL, "C:\\Users\\Amber\\AppData\\Roaming\\MetaQuotes\\Terminal\\DEA332DEFF5165CB2EAFB6F9BD062C50\\MQL5\\Experts\\Advisors\\PythonDLL_Example.py", "125960 126110 126070 126250 3928 274353.845945816 119761.8349277858 18080.59072693367 -252416.3714632094 -79682.09253258759 -12446.11663140202", NULL, SW_HIDE);
Related
I am trying to do an Xcode build in Gradle. Requirements:
Some of my arguments have spaces in them.
I want to pipe the output through xcpretty. Otherwise gitlab complains that there is too much output and I can't see any errors toward the end of the build
I don't want to wait for the command to complete before seeing the output. I want to be able to watch it build, like any ci job
Gradle exec{} doesn't seem to let me pipe the output while building. I can save the output to a file but that doesn't let me watch the build
I.e.,
exec {
executable 'xcodebuild'
ext.output = {
return standardOutput.toString()
}
args = [
'archive',
'-project',
"${buildDir}/iPhone/Unity-iPhone.xcodeproj/",
"-archivePath",
"${buildDir}/iPhone/Unity-iPhone.xcarchive",
"-sdk", "iphoneos",
"GCC_GENERATE_DEBUGGING_SYMBOLS=YES",
"DEBUG_INFORMATION_FORMAT=dwarf-with-dsym",
"DWARF_DSYM_FILE_SHOULD_ACCOMPANY_PRODUCT=NO",
"DWARF_DSYM_FOLDER_PATH=iOS_Dsym",
"DEBUGGING_SYMBOLS=YES",
"DEVELOPMENT_TEAM=RPGSNMH65P",
"CODE_SIGN_IDENTITY=${appleIdentity}",
"CODE_SIGN_STYLE=Manual",
"USYM_UPLOAD_AUTH_TOKEN=${appcenter_login_token}",
"PROVISIONING_PROFILE_SPECIFIER_APP=${provisioningProfile}",
"-configuration", "Release",
"-scheme", "${schemeName}",
"| xcpretty"
]
}
doesn't work
I can't use groovy "xcodebuild ... CODE_SIGN_IDENTITY=${"${appleIdentity}"} ... | xcpretty".execute() because my code signing identity contains spaces and for some reason groovy wants to stick its own quotes into the command string when it finds spaces.
I tried the array execute method but ended up with the same problem.
def cmd = [
'xcodebuild ',
'archive',
'-project',
"${buildDir}/iPhone/Unity-iPhone.xcodeproj/",
"-archivePath",
"${buildDir}/iPhone/Unity-iPhone.xcarchive",
"-sdk", "iphoneos",
"GCC_GENERATE_DEBUGGING_SYMBOLS=YES",
"DEBUG_INFORMATION_FORMAT=dwarf-with-dsym",
"DWARF_DSYM_FILE_SHOULD_ACCOMPANY_PRODUCT=NO",
"DWARF_DSYM_FOLDER_PATH=iOS_Dsym",
"DEBUGGING_SYMBOLS=YES",
"DEVELOPMENT_TEAM=RPGSNMH65P",
"CODE_SIGN_IDENTITY=${appleIdentity}",
"CODE_SIGN_STYLE=Manual",
"USYM_UPLOAD_AUTH_TOKEN=${appcenter_login_token}",
"PROVISIONING_PROFILE_SPECIFIER_APP=${provisioningProfile}",
"-configuration", "Release",
"-scheme", "${schemeName}"
]
println cmd
def proc = cmd.execute()
... except that it's even harder to debug because I can't see the actual command being executed.
I have found various solutions online but nothing that fits these requirements
how to use choice parameter in Jenkins declarative pipeline in batch command.
I'm using following stage:
choice(
choices: 'apply\ndestroy\n',
description: '',
name: 'DESTROY_OR_APPLY')
stage ('temp') {
steps {
echo "type ${params.DESTROY_OR_APPLY}"
bat'echo "type01 ${params.DESTROY_OR_APPLY}"'
bat'echo "type01 %{params.DESTROY_OR_APPLY}%"'
bat'echo type01 [${params.DESTROY_OR_APPLY}]'
}
echo does resolve to correct parameter value but under bat none of the above code works.
You almost got the syntax right.
If you change it to one of the below options, the bat command receives the value of your choice.
steps {
bat "echo type01 ${DESTROY_OR_APPLY}"
}
or
steps {
bat 'echo type01 ' + DESTROY_OR_APPLY
}
You can also use ${params.DESTROY_OR_APPLY} in the first or params.DESTROY_OR_APPLY in the second example if you want to use the params definition consequently in your code.
I have a korn shell script which will pass 4 parameters to a Pro*C file
The syntax of the korn shell script are below:
### $command_dir/proc_file_name / $deptid $txdate $pid
### I hardcode the values for testing
$command_dir/proc_file_name / 701 20170109 201701094444001
The syntax of the Pro*C file:
....
main(argc, argv)
int argc
char *argv[];
username.len=strlen(argv[1]);
strncpy((char*)username.arr, argv[1],username.len);
username.arr[username.len]='\0';
deptid.len=strlen(argv[1]);
strncpy((char*)deptid.arr, argv[1],deptid.len);
deptid.arr[deptid.len]='\0';
txdate.len=strlen(argv[1]);
strncpy((char*)txdate.arr, argv[1],txdate.len);
txdate.arr[txdate.len]='\0';
pid=atoi(argv[4]);
printf("\n%s\n", username);
printf("\n%d\n", deptid);
printf("\n%d\n", txdate);
printf("\n%d\n", pid);
....
I found that the values of the parameters were not I put.
Please help...
Many Many thanks
You are using the same array index of 1 for username, deptid, and txdate. Correct that and you would be good.
Accessing argv[1] etc., without checking argc isn't a good practice. When invoked without arguments, your code will result in a core dump.
Also, I don't think your code has the right syntax. Can you please paste the code that compiles?
I am executing some sql queries using OSQL through inno setup. I am using following code to run OSQL. This is just for example purpose
SQLQuery:= '"EXEC sp_addserver ''PCNAME'';"';
Param:= '-S(local) -Usa -Psa -Q ' + SQLQuery;
Exec('osql.exe', Param, '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
This works fine. The problem is ResultCode value is always 0. Even if the query does not get executed. For example if I try same query like below where I pass in an invalid stored procedure name the ResultCode is still 0.
SQLQuery:= '"EXEC sp_invalidname ''PCNAME'';"';
Param:= '-S(local) -Usa -Psa -Q ' + SQLQuery;
Exec('osql.exe', Param, '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Why don't this return me a proper code. If I run the second query in management studio I get an error like this
Msg 2812, Level 16, State 62, Line 1
Could not find stored procedure 'sp_invalidname'
Here return code is 2812. Why dont I get this when I run it through inno. What do I need to do to get this error code in inno?
Thanks to TLama, I updated my code as below and its working now. I had to add -b command line parameter and now it returns 1 if the command fails.
-b
Specifies that osql exits and returns a DOS ERRORLEVEL value when an error occurs. The value returned to the DOS ERRORLEVEL variable is 1 when the SQL Server error message has a severity of 11 or greater; otherwise, the value returned is 0. Microsoft MS-DOS batch files can test the value of DOS ERRORLEVEL and handle the error appropriately.
I updated my code as below.
Param:= '-S(local) -Usa -Psa -b -Q ' + SQLQuery;
Its explained in the documentation.
I'm trying to compile someone's mod of minecraft so that I can make some changes to it. It uses scala somewhere in the recompiling, and I get this error:
== ERRORS FOUND in SCALA CODE ==
The command line is too long.
================================
I tend to agree:
'"scalac.bat" -encoding UTF-8 -deprecation -target:jvm-1.6 -classpath "jars\vers
ions\1.8.1\1.8.1.jar;lib;lib\*;lib;lib\*;jars\bin\minecraft.jar;jars\bin\jinput.
jar;jars\bin\lwjgl.jar;jars\bin\lwjgl_util.jar;jars\libraries\net\java\jinput\ji
nput\2.0.5\jinput-2.0.5.jar;jars\libraries\org\lwjgl\lwjgl\lwjgl-platform\2.9.1\
lwjgl-platform-2.9.1-natives-windows.jar;jars\libraries\com\ibm\icu\icu4j-core-m
ojang\51.2\icu4j-core-mojang-51.2.jar;jars\libraries\tv\twitch\twitch-external-p
latform\4.5\twitch-external-platform-4.5-natives-windows-64.jar;jars\libraries\c
om\sixense\SixenseJavaLibrary\062612.0\SixenseJavaLibrary-062612.0-natives-windo
ws.jar;jars\libraries\org\apache\httpcomponents\httpcore\4.3.2\httpcore-4.3.2.ja
r;jars\libraries\org\apache\logging\log4j\log4j-api\2.0-beta9\log4j-api-2.0-beta
9.jar;jars\libraries\org\apache\commons\commons-lang3\3.3.2\commons-lang3-3.3.2.
jar;jars\libraries\net\java\jutils\jutils\1.0.0\jutils-1.0.0.jar;jars\libraries\
com\paulscode\libraryjavasound\20101123\libraryjavasound-20101123.jar;jars\libra
ries\net\sf\jopt-simple\jopt-simple\4.6\jopt-simple-4.6.jar;jars\libraries\com\g
oogle\guava\guava\17.0\guava-17.0.jar;jars\libraries\commons-logging\commons-log
ging\1.1.3\commons-logging-1.1.3.jar;jars\libraries\org\apache\commons\commons-c
ompress\1.8.1\commons-compress-1.8.1.jar;jars\libraries\com\sixense\SixenseJava\
062612.1\SixenseJava-062612.1.jar;jars\libraries\tv\twitch\twitch\6.5\twitch-6.5
.jar;jars\libraries\com\paulscode\codecjorbis\20101023\codecjorbis-20101023.jar;
jars\libraries\optifine\OptiFine\1.8.1_HD_U_B2\OptiFine-1.8.1_HD_U_B2.jar;jars\l
ibraries\com\paulscode\soundsystem\20120107\soundsystem-20120107.jar;jars\librar
ies\org\json\json\20140107\json-20140107.jar;jars\libraries\com\paulscode\librar
ylwjglopenal\20100824\librarylwjglopenal-20100824.jar;jars\libraries\org\lwjgl\l
wjgl\lwjgl_util\2.9.1\lwjgl_util-2.9.1.jar;jars\libraries\commons-codec\commons-
codec\1.9\commons-codec-1.9.jar;jars\libraries\org\apache\httpcomponents\httpcli
ent\4.3.3\httpclient-4.3.3.jar;jars\libraries\de\fruitfly\ovr\JRiftLibrary\0.4.4
.1\JRiftLibrary-0.4.4.1-natives-windows.jar;jars\libraries\org\lwjgl\lwjgl\lwjgl
\2.9.1\lwjgl-2.9.1.jar;jars\libraries\commons-io\commons-io\2.4\commons-io-2.4.j
ar;jars\libraries\com\mojang\realms\1.7.4\realms-1.7.4.jar;jars\libraries\net\ai
b42\mumblelink\JMumbleLibrary\1.1\JMumbleLibrary-1.1-natives-windows.jar;jars\li
braries\com\mojang\authlib\1.5.17\authlib-1.5.17.jar;jars\libraries\com\google\c
ode\gson\gson\2.2.4\gson-2.2.4.jar;jars\libraries\net\minecraft\launchwrapper\1.
7\launchwrapper-1.7.jar;jars\libraries\com\paulscode\codecwav\20101023\codecwav-
20101023.jar;jars\libraries\tv\twitch\twitch-platform\6.5\twitch-platform-6.5-na
tives-windows-64.jar;jars\libraries\net\java\jinput\jinput-platform\2.0.5\jinput
-platform-2.0.5-natives-windows.jar;jars\libraries\de\fruitfly\ovr\JRift\0.4.4.1
\JRift-0.4.4.1.jar;jars\libraries\org\apache\logging\log4j\log4j-core\2.0-beta9\
log4j-core-2.0-beta9.jar;jars\libraries\net\aib42\mumblelink\JMumble\1.0\JMumble
-1.0.jar;jars\libraries\io\netty\netty-all\4.0.23.Final\netty-all-4.0.23.Final.j
ar" -sourcepath src\minecraft -d bin\minecraft src\minecraft\*.java src\minecraf
t\net\minecraft\block\*.java src\minecraft\net\minecraft\block\material\*.java s
rc\minecraft\net\minecraft\block\properties\*.java src\minecraft\net\minecraft\b
lock\state\*.java src\minecraft\net\minecraft\block\state\pattern\*.java src\min
ecraft\net\minecraft\client\*.java src\minecraft\net\minecraft\client\audio\*.ja
va src\minecraft\net\minecraft\client\entity\*.java src\minecraft\net\minecraft\
client\gui\*.java src\minecraft\net\minecraft\client\gui\achievement\*.java src\
minecraft\net\minecraft\client\gui\inventory\*.java src\minecraft\net\minecraft\
client\gui\spectator\*.java src\minecraft\net\minecraft\client\gui\spectator\cat
egories\*.java src\minecraft\net\minecraft\client\gui\stream\*.java src\minecraf
t\net\minecraft\client\main\*.java src\minecraft\net\minecraft\client\model\*.ja
va src\minecraft\net\minecraft\client\multiplayer\*.java src\minecraft\net\minec
raft\client\network\*.java src\minecraft\net\minecraft\client\particle\*.java sr
c\minecraft\net\minecraft\client\player\inventory\*.java src\minecraft\net\minec
raft\client\renderer\*.java src\minecraft\net\minecraft\client\renderer\block\mo
del\*.java src\minecraft\net\minecraft\client\renderer\block\statemap\*.java src
\minecraft\net\minecraft\client\renderer\chunk\*.java src\minecraft\net\minecraf
t\client\renderer\culling\*.java src\minecraft\net\minecraft\client\renderer\ent
ity\*.java src\minecraft\net\minecraft\client\renderer\entity\layers\*.java src\
minecraft\net\minecraft\client\renderer\texture\*.java src\minecraft\net\minecra
ft\client\renderer\tileentity\*.java src\minecraft\net\minecraft\client\renderer
\vertex\*.java src\minecraft\net\minecraft\client\resources\*.java src\minecraft
\net\minecraft\client\resources\data\*.java src\minecraft\net\minecraft\client\r
esources\model\*.java src\minecraft\net\minecraft\client\settings\*.java src\min
ecraft\net\minecraft\client\shader\*.java src\minecraft\net\minecraft\client\str
eam\*.java src\minecraft\net\minecraft\client\util\*.java src\minecraft\net\mine
craft\command\*.java src\minecraft\net\minecraft\command\common\*.java src\minec
raft\net\minecraft\command\server\*.java src\minecraft\net\minecraft\crash\*.jav
a src\minecraft\net\minecraft\creativetab\*.java src\minecraft\net\minecraft\dis
penser\*.java src\minecraft\net\minecraft\enchantment\*.java src\minecraft\net\m
inecraft\entity\*.java src\minecraft\net\minecraft\entity\ai\*.java src\minecraf
t\net\minecraft\entity\ai\attributes\*.java src\minecraft\net\minecraft\entity\b
oss\*.java src\minecraft\net\minecraft\entity\effect\*.java src\minecraft\net\mi
necraft\entity\item\*.java src\minecraft\net\minecraft\entity\monster\*.java src
\minecraft\net\minecraft\entity\passive\*.java src\minecraft\net\minecraft\entit
y\player\*.java src\minecraft\net\minecraft\entity\projectile\*.java src\minecra
ft\net\minecraft\event\*.java src\minecraft\net\minecraft\init\*.java src\minecr
aft\net\minecraft\inventory\*.java src\minecraft\net\minecraft\item\*.java src\m
inecraft\net\minecraft\item\crafting\*.java src\minecraft\net\minecraft\nbt\*.ja
va src\minecraft\net\minecraft\network\*.java src\minecraft\net\minecraft\networ
k\handshake\*.java src\minecraft\net\minecraft\network\handshake\client\*.java s
rc\minecraft\net\minecraft\network\login\*.java src\minecraft\net\minecraft\netw
ork\login\client\*.java src\minecraft\net\minecraft\network\login\server\*.java
src\minecraft\net\minecraft\network\play\*.java src\minecraft\net\minecraft\netw
ork\play\client\*.java src\minecraft\net\minecraft\network\play\server\*.java sr
c\minecraft\net\minecraft\network\status\*.java src\minecraft\net\minecraft\netw
ork\status\client\*.java src\minecraft\net\minecraft\network\status\server\*.jav
a src\minecraft\net\minecraft\pathfinding\*.java src\minecraft\net\minecraft\pot
ion\*.java src\minecraft\net\minecraft\profiler\*.java src\minecraft\net\minecra
ft\realms\*.java src\minecraft\net\minecraft\scoreboard\*.java src\minecraft\net
\minecraft\server\*.java src\minecraft\net\minecraft\server\gui\*.java src\minec
raft\net\minecraft\server\integrated\*.java src\minecraft\net\minecraft\server\m
anagement\*.java src\minecraft\net\minecraft\server\network\*.java src\minecraft
\net\minecraft\src\*.java src\minecraft\net\minecraft\stats\*.java src\minecraft
\net\minecraft\tileentity\*.java src\minecraft\net\minecraft\util\*.java src\min
ecraft\net\minecraft\village\*.java src\minecraft\net\minecraft\world\*.java src
\minecraft\net\minecraft\world\biome\*.java src\minecraft\net\minecraft\world\bo
rder\*.java src\minecraft\net\minecraft\world\chunk\*.java src\minecraft\net\min
ecraft\world\chunk\storage\*.java src\minecraft\net\minecraft\world\demo\*.java
src\minecraft\net\minecraft\world\gen\*.java src\minecraft\net\minecraft\world\g
en\feature\*.java src\minecraft\net\minecraft\world\gen\layer\*.java src\minecra
ft\net\minecraft\world\gen\structure\*.java src\minecraft\net\minecraft\world\pa
thfinder\*.java src\minecraft\net\minecraft\world\storage\*.java src\minecraft\o
ptifine\*.java src\minecraft\optifine\json\*.java' failed : 1
Given that windows has a character limit on the command line.
I'm using windows 8.1 and scala 2.11.0.
I was wondering, is there a way to set this as an environment/path variable or something to avoid this?
What would I have to change? I'm very new to messing around with system stuff like this, but I think I know where scala is called in the scripts and this argument is given. If that helps.
scalac accepts an #file parameter containing a file with arguments in. So if you can modify whatever script is calling scalac.bat to instead put the arguments in a temporary file arguments.txt and then call scalac #arguments.txt that should work.