View Full Version : CallCmd v1.04 - x86 & x64 -Execute command
dani75
15th June 2020, 19:00
Hi everybody, hi StainlessS
I wrote
I tried it, even with "CallCmd_x86.dll". Sorry, no change at all, except in the instruction line
I tried a lot of stuff to solve this, including repairing .NET Framework and a sfc /scannow on my PC, shrinking my AVS script to a copy-paste of your 3 lines, etc.
and now, "hello world" appears correctly on the console. Yeah !
But I don't know what was the problem (typing error is not excluded).
A problem remains with the arguments of the command. I describe it hereunder.
I try to invoke a commande which path is included in an avisynth variable named "MyPath", which name is the string "MyProgram.exe", and which single argument is the full name of a file (path and name) named "MyFile".
Both pathes above contains a space character (one starting with "C:\Program Files (x86)"). Therefore I made use of a pair of double quotes surrounding the path of the command inside the three-double quotes pair on the "CallCmd" line :
CallCmd(Last,Open="""cmd /C """"+MyPath+"""MyProgram.exe" & pause""",Debug=True)
Therefore there is a pair of 4 double-quotes on the left of the path. This is running perfectly, "MyProgram.exe" is really called from the script.
Now I want to add my single argument, so I wrote :
CallCmd(Last,Open="""cmd /C """"+MyPath+"""MyProgram.exe" """"+MyFile+"""" & pause""",Debug=True)
I got the following message on the console (I translate it from french) : 'C:\Program is not recognized neither as an internal nor external command, an executable program or a command file'
It appears that adding "real" double quotes surrounding the "MyFile" argument breaks the parsing of the command, and that the path of the command is broken at the space character.
This is very hard to explain, I am sorry if I have introduced too much confusion.
Can anybody help me passing a single argument to MyProgram on a CallCmd() command ?
StainlessS
15th June 2020, 19:35
Thankyou for the added info, however,
can you provide the strings MyPath and MyFile, and is the program name really MyProgram.exe,
there can be a lot of screwing around, its not CallCmd but the cmd.exe and programs called that can be the problem,
some programs work differently to others. A big problem is also having any spaces in paths or filenames eg "...Program Files...".
Also, Can I suggest something like this.
Function QuoteStr(String s) { return Chr(34) + s + Chr(34) } # And use Quotestr for paths containing Spaces
PROG_S = QuoteStr(MyPath + "MyProgram.exe") # I assume MyPath ends with backslash
RT_DebugF("PROG_S = '%s'",PROG_S,name="Dani75: ") # From RT_Stats
OpenCmd = "cmd /C " + PROG_S + " " + MyFile # + " & pause" was intended only for testing and might make it harder to get working, try without it.
RT_DebugF("OpenCmd = '%s'",OpenCmd,name="Dani75: ") # From RT_Stats
CallCmd(Last,Open=OpenCmd,Debug=True)
EDIT: You might also try without CMD /C [I think we used CMD /C mainly for calling DOS builtin commands, eg DEL or DIR]
eg
CallCmd(Blankclip,"C:\PortableApps\ImageMagick\Mogrify.exe -flop C:\Temp\#.tif", "0,0",Insert="#",Once=false,Hide=true,Debug=true)
EDIT: And the " & pause" at end of line may only work if the command is a console/CLI/DOS style builtin command, otherwise YOUR program may not have any idea what to do with it.
The command must at least work typing in via the CLI console.
dani75
15th June 2020, 20:48
Hi StainlessS
Thanks for your help
Here are the variables I use :
MyPath is RepertoireSysteme="C:\Program Files (x86)\StudioTransfert\Outils"
MyProgram.exe is Trad_Orph_AviSynth.exe
MyFile is FichierOrphelines="F:\Enregistrements DVD\8mm\Le transfert pellicule\DSCN2246.MOV-370@395.txt"
In a command prompt window, the following runs correctly :
"C:\Program Files (x86)\StudioTransfert\Outils\Trad_Orph_AviSynth.exe" "F:\Enregistrements DVD\8mm\Le transfert pellicule\DSCN2246.MOV-370@395.txt"
But if I prefix the same stuff with
cmd /C
I get :
'C:\Program is not recognized neither as an internal nor external command, an executable program or a command file'
I tried your code, but I got a void response before "hit a key to continue" on the console. On DebugView is displayed the following :
[14788] Dani75: PROG_S = '"C:\Program Files (x86)\StudioTransfert\Outils\Trad_Orph_AviSynth.exe"'
[14788] Dani75: OpenCmd = 'cmd /C "C:\Program Files (x86)\StudioTransfert\Outils\Trad_Orph_AviSynth.exe" F:\Enregistrements DVD\8mm\Le transfert pellicule\DSCN2246.MOV-370@395.txt & pause'
The argument is not surounded by double quotes, therefore the interpretation fails dealing with the white space.
I tried to surround the argument by double quotes, exactly like you did for the executable with QuoteStr().
I got again the message about 'C:\Program...' and on the DebugView console was displayed :
[13748] Dani75: PROG_S = '"C:\Program Files (x86)\StudioTransfert\Outils\Trad_Orph_AviSynth.exe"'
[13748] Dani75: OpenCmd = 'cmd /C "C:\Program Files (x86)\StudioTransfert\Outils\Trad_Orph_AviSynth.exe" "F:\Enregistrements DVD\8mm\Le transfert pellicule\DSCN2246.MOV-370@395.txt" & pause'
I am going to be mad...
StainlessS
15th June 2020, 21:01
Try this
Function QuoteStr(String s) { return Chr(34) + s + Chr(34) } # And use Quotestr for paths containing Spaces
RepertoireSysteme = "C:\Program Files (x86)\StudioTransfert\Outils"
MyProgram = "Trad_Orph_AviSynth.exe"
FichierOrphelines = "F:\Enregistrements DVD\8mm\Le transfert pellicule\DSCN2246.MOV-370@395.txt"
PROGNAME = QuoteStr(RepertoireSysteme + "\" + MyProgram)
MYFILE = QuoteStr(FichierOrphelines)
OpenCmd = PROGNAME + " " + MYFILE
BlankClip.CallCmd(Open=OpenCmd,Debug=True)
If fails then try (as alternative at end of above)
BlankClip.CallCmd(Open="CMD /C " + OpenCmd,Debug=True)
dani75
15th June 2020, 21:28
This was not better.
The only test I made run correctly is, after having moved DSCN2246.MOV-370@395.txt in a place where the path has not white space included :
FichierOrphelines = "F:DSCN2246.MOV-370@395.txt"
Function QuoteStr(String s) { return Chr(34) + s + Chr(34) } # And use Quotestr for paths containing Spaces
PROG_S = QuoteStr(RepertoireSysteme + "Trad_Orph_AviSynth.exe") # I assume MyPath ends with backslash
ARG_S = FichierOrphelines
RT_DebugF("PROG_S = '%s'",PROG_S,name="Dani75: ") # From RT_Stats
OpenCmd = "cmd /C " + PROG_S + " " + ARG_S + " & pause" # + " & pause" was intended only for testing and might make it harder to get working, try without it.
RT_DebugF("OpenCmd = '%s'",OpenCmd,name="Dani75: ") # From RT_Stats
CallCmd(Last,Open=OpenCmd,Debug=True)
In this situation, there is not double quotes surrounding the arguments. But I cannot keep the DSCN2246.MOV-370@395.txt file there !
EDIT: in your penultimate proposal you removed the cmd /C command, but I need it, because later on I will add the redirection of the std output to a file whose path is in a variable !
dani75
15th June 2020, 21:45
The following runs correctly :
FichierOrphelines = "F:DSCN2246.MOV-370@395.txt"
Function QuoteStr(String s) { return Chr(34) + s + Chr(34) } # And use Quotestr for paths containing Spaces
PROGNAME = QuoteStr(RepertoireSysteme + "\" + "Trad_Orph_AviSynth.exe")
MYFILE = FichierOrphelines
OpenCmd = PROGNAME + " " + MYFILE + "& pause"
CallCmd(Open="CMD /C " + OpenCmd,Debug=True)
If I remove the "& pause", the console disappears immediately after CallCmd execution, but I can see there is nothing displayed on it
If I move DSCN2246.MOV-370@395.txt to its previous path with a whitespace embeded, my program does not run. It seems that the only problem is that whitespace.
dani75
16th June 2020, 13:02
I have chosen another way to solve this stuff not being bothered by that whitespace on a CMD command line, simple and efficient : I make a temporary .bat file which contains the full command (with its argument and redirection of the std output), and pass it to CallCmd() without argument and without CMD.
Thank you StainlessS for having tried to help me.
Groucho2004
17th June 2020, 10:57
Groucho, what is red stuff below supposed to be ? [for post #33 script, below done on W7]
d:\TESt>avsmeter callcmd.avs
AVSMeter 3.0.1.0 (x86), (c) Groucho2004, 2012-2020
AviSynth+ 3.6.1 (r3290, master, i386) (3.6.1.0)
Hello world pt...
Press any key to continue . . .
I finally figured it out. Will be fixed in the next build.
StainlessS
17th June 2020, 18:01
I make a temporary .bat file
Oh good, I'm glad you got it sorted. I was out most of yesterday and pretty much forgot all about this thread,
and night before I was exhausted and could not bring myself to try figure out the problem, SPACES in filenames are a real
problem sometimes, I hates them.
You should take care of adding backslash in eg here "F:\path", ie full path, "F:path" used to mean current directory for the F: drive, not sure how it behaves on recent systems.
FichierOrphelines = "F:DSCN2246.MOV-370@395.txt" # missing backslash
If you do forum search on "CallCmd", and check out stuff by Martin53, you see lots of problems that needed to be overcome for particular
executables that sometime behave a little peculiar, sometimes need quotes, sometime not, and the 'tricks' need to overcome the probs.
I finally figured it out. Will be fixed in the next build.
Guess your gonna keep it a secret.
Groucho2004
17th June 2020, 18:11
Guess your gonna keep it a secret.I'll explain later, busy making dinner right now.
StainlessS
17th June 2020, 20:46
fava beans and a nice bottle of chianti ?
Groucho2004
17th June 2020, 22:12
fava beans and a nice bottle of chianti ?Tortellini with Grouchy Cream Sauce™.
Your callcmd plug prints console output when the script is loaded (env->Invoke("Import", ...). This output overwrote parts of the "Loading script..." message the came right before the import statement.
Groucho2004
23rd June 2020, 18:23
By the way, the "Cosmetics" fix in AVSMeter 3.0.2.0 is related to my post above (not the cream sauce). It should not overwrite the output of callcmd() any more.
StainlessS
23rd June 2020, 20:54
It should not overwrite the output of callcmd() any more.
Thanks Muchly :)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.