Just a quicky, since it's something I've often wanted, and the subject came up on fusion-l recently - a console util to copy a bitmap on the system clipboard to a file, and a simple fuse to load it back into Fusion.
Seems like os.execute can't handle two paths in ".While the commandline can and it makes perfect sense. Maybe it tries to execute it as two commands?!
Since my temp file has no whitespaces this works: ('\"' .. localdir .. 'clipboard2bmp.exe\" ' .. filepath)
Situations like this make me hate lua. And its "documentation". Any smart solution other than wrapping the path/command inside a batch file?
As a side-note until the console outputs what lua does. You can add a "& pause" or "> file.txt" to the end of you lua command to see what it actually outputs.
I'm more interesting in the bit where you can just run scripts, including os.execute via the fuse UI and also where you can just load an image with Clip.
The os.execute() command is somewhat at the mercy of the command prompt it seems - though as you say it doesn't work exactly the same way, either. Running with a different command prompt, such as TCC/LE, shows different behaviour again.
A better solution is probably to use eyeon.executebg(), which uses a direct win32 call to create the process and should bypass console issues:
On line 32 use:
ReplyDeleteos.execute('"'..localdir..'clipboard2bmp.exe" "'..filepath..'"')
.. instead. So if clipboard2bmp is in folders with whitespaces it will work ;-)
Besides, great work!
No there must be something else wrong. The exec still doesn't work as expected.
ReplyDeleteBtw. this is a great moment to say that it would totally rock if we could output the os.exec stdout to console.
Seems like os.execute can't handle two paths in ".While the commandline can and it makes perfect sense. Maybe it tries to execute it as two commands?!
ReplyDeleteSince my temp file has no whitespaces this works:
('\"' .. localdir .. 'clipboard2bmp.exe\" ' .. filepath)
Situations like this make me hate lua. And its "documentation".
Any smart solution other than wrapping the path/command inside a batch file?
As a side-note until the console outputs what lua does. You can add a "& pause" or "> file.txt" to the end of you lua command to see what it actually outputs.
I'm more interesting in the bit where you can just run scripts, including os.execute via the fuse UI and also where you can just load an image with Clip.
ReplyDeleteThe os.execute() command is somewhat at the mercy of the command prompt it seems - though as you say it doesn't work exactly the same way, either. Running with a different command prompt, such as TCC/LE, shows different behaviour again.
ReplyDeleteA better solution is probably to use eyeon.executebg(), which uses a direct win32 call to create the process and should bypass console issues:
eyeon.executebg('"'..localdir..'clipboard2bmp.exe" "'..filepath..'"', true)
Note the final true argument tells executebg to wait for the command to terminate before returning, rather than running it asynchronously.
I updated the fuse & exe to no longer require quoting the filepath, which simplifies things.
ReplyDelete