Problems with Execute()

Report any Hollywood bugs here
Post Reply
User avatar
Allanon
Posts: 461
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Problems with Execute()

Post by Allanon » Sun Feb 17, 2019 11:00 am

Hello, I have this issue on WIndows 10 + Hollywood 8:

I'm trying to execute an external program and redirect the output to a file, the built command string works fine if I run it from the shell directly but for some reasons using the Execute() command does not produce any output.

During my tests I've tried to execute simple commands to test the redirection, for example :

Code: Select all

Execute("dir >text")
But a system error popup saying that "<path_to_my_script>/dir" cannot be found... is it the standard behaviour? Should I provide full path to the dir command?
To be honest I don't remember if I had to provide full paths for system commands in HW7...

Anyway, let's return to my original problem, to simplify things I've made a test with the 7zip executable, here is the test code:

Code: Select all

      Execute(dq .. "C:\\Program Files\\7-Zip\\7z.exe" .. dq .. " >C:\\test\\log.txt")
      DebugPrint(dq .. "C:\\Program Files\\7-Zip\\7z.exe" .. dq .. " >C:\\test\\log.txt")
the dq variable holds a double-quote character.

If I run the above code no output is generated, If I copy & paste the output that the DebugPrint() prints to a shell and I execute it the output is correctly generate... maybe I'm just getting confused with double-quotes... :?
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

User avatar
airsoftsoftwair
Posts: 2985
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Problems with Execute()

Post by airsoftsoftwair » Mon Feb 18, 2019 4:35 pm

Are you sure that this was possible in previous versions? AFAICS this is impossible to do directly from Execute() or Run() because they operate in Shell's context which doesn't have stdin and stdout. So you need to use some tricks to get the output, e.g. you could use cmd.exe to create a console context that captures the output, like so:

Code: Select all

Execute("c:\\windows\\system32\\cmd.exe /c dir > out.txt")
Alternatively, you could also use Execute() on a batch script that runs the program and captures the output.

User avatar
Allanon
Posts: 461
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Problems with Execute()

Post by Allanon » Mon Feb 18, 2019 6:21 pm

I've found what I've done previously in an old project (file date says 2012!! Wow!!) :shock:
I've used the cmd.exe command like you have suggested in a shell script :)

Thank you for the tip!
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

Post Reply