|
|
|
06-19-2018, 07:40 AM
|
#1
|
Human being with feelings
Join Date: May 2018
Location: Stony Brook, New York
Posts: 3
|
os.execute in REAPER script under Wine.
I am probably doing something pretty stupid, as I'm pretty new to Lua.
I have a small bash script I'd like to run from a custom REAPER command, (it's for cleaning up a student user directory when they've inevitably sprayed files all over the place, as they are wont to do).
I'm running REAPER under WINE in Linux, and all my other .lua scripts work fine, but when I try to call os.execute("sh ~/MyScript.sh") nothing happens.
I checked the return value on os.execute("sh ~/MyScript.sh") and it's coming back nil, though it returns 'true' if I run other commands, such as os.execute("echo test-value")
When I run direct from the terminal, it works just fine, so I don't think the fault lies in the script itself but how I'm calling it. Also, works just as intended on OsX, so this could be my being dumb about Linux.
Here's a highly-simplified version of the entire script:
--Test Script for os.execute Reaper on WINE
--Command as written runs in terminal, but fails in a REAPER script.
local function Msg(str)
reaper.ShowConsoleMsg(tostring(str).."\n")
end
--quick debug message
Msg(os.execute('sh ~/MkDirMvFiles.sh'))
--Msg(package.config:sub(1,1))
--Gets the path seperator, which tells us whether Lua thinks she's in Windows or Unix. Returns "/" rather than "\" on Wine, so Unix?
|
|
|
06-19-2018, 09:14 AM
|
#2
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
- I'd include the shell script anyway just in case
- For better readability on the forum, you can put code inside [ code ] and [/ code ] tags (remove the spaces) or use the # button in the post editor (I think it has to be in advanced mode or something... it gives you buttons for bold, underline, center, bullets, etc)
- Not sure if Linux needs something similar, but for Windows you need to make sure that sh's root folder is part of the system path to be able to call it from anywhere you want as opposed to c:/shellscript/bin/sh
- Regarding the last line of your Lua script, AFAIK all three OSes will play happily with / as a separator, so you shouldn't have to worry about it. Mac and Linux use / I believe, and Windows doesn't even care if I mix the two: c:\users\me\appdata/roaming\REAPER/scripts\lokasenna/testing.lua.
|
|
|
06-19-2018, 09:26 AM
|
#3
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
Try the following:
Every command in your shell-sript should include the absolute path to the command. See if that works.
With the windows version of os.execute, I've seen the problem occuring, that no environment-variables were set in the "command-line-instance" executed by os.execute. That way, no command could be found that wasn't part of cmd.exe.
Maybe that is the same problem on Linux.
You can also check out:
https://www.reaper.fm/sdk/reascript/...ml#ExecProcess
which is Reaper's own execute-function.
SWS also has one, called reaper.BR_Win32_ShellExecute(). It is only available, when you have SWS installed, though.
|
|
|
02-27-2021, 06:08 AM
|
#4
|
Human being with feelings
Join Date: Oct 2014
Location: Belgium
Posts: 1,612
|
Quote:
Originally Posted by mespotine
Try the following:
Every command in your shell-sript should include the absolute path to the command. See if that works.
With the windows version of os.execute, I've seen the problem occuring, that no environment-variables were set in the "command-line-instance" executed by os.execute. That way, no command could be found that wasn't part of cmd.exe.
Maybe that is the same problem on Linux.
You can also check out:
https://www.reaper.fm/sdk/reascript/...ml#ExecProcess
which is Reaper's own execute-function.
SWS also has one, called reaper.BR_Win32_ShellExecute(). It is only available, when you have SWS installed, though.
|
how to deal with spaces?
Code:
os.execute("start c:/program files/blablabla/bla.exe")
it returns
Code:
Windows cannot fine 'C:/Program'. Make sure you typed the name correctly, and then try again.
[/code]
|
|
|
02-27-2021, 09:00 AM
|
#5
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
Enclose these filenames with
|
|
|
02-27-2021, 12:01 PM
|
#6
|
Human being with feelings
Join Date: Oct 2014
Location: Belgium
Posts: 1,612
|
Quote:
Originally Posted by Meo-Ada Mespotine
Enclose these filenames with
|
I tried. It didn't get it. I had to write progra~2 instead. Old DOS stuff :-)
|
|
|
02-27-2021, 01:12 PM
|
#7
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
Have you tried using backslashes as folder-separator? Even though Lua tries to convert them automatically, I wouldn't trust Lua with that.
Especially as the line in os.execute is interpreted by the command line and not Lua.
|
|
|
02-28-2021, 03:15 AM
|
#8
|
Human being with feelings
Join Date: Mar 2013
Posts: 5,844
|
Quote:
Originally Posted by BartR
how to deal with spaces?
Code:
os.execute("start c:/program files/blablabla/bla.exe")
|
Here are some examples:
Code:
local path = "c:/program files/blablabla/bla.exe"
os.execute('start "" "' .. path .. '"')
Code:
local path = "c:/program files/blablabla/bla.exe"
reaper.BR_Win32_ShellExecute("open", path, "", "", 1)
Code:
local directory = "c:/program files/blablabla"
local fileName = "bla.exe"
reaper.BR_Win32_ShellExecute("open", fileName, "", directory , 1)
|
|
|
02-28-2021, 04:25 AM
|
#9
|
Human being with feelings
Join Date: Oct 2014
Location: Belgium
Posts: 1,612
|
Quote:
Originally Posted by Meo-Ada Mespotine
Have you tried using backslashes as folder-separator? Even though Lua tries to convert them automatically, I wouldn't trust Lua with that.
Especially as the line in os.execute is interpreted by the command line and not Lua.
|
Yes I did try but it was not working.
For the rest I agree with you about the reliability.
I will try some other stuff again.
|
|
|
02-28-2021, 05:15 AM
|
#10
|
Human being with feelings
Join Date: Oct 2014
Location: Belgium
Posts: 1,612
|
Quote:
Originally Posted by solger
Here are some examples:
Code:
local path = "c:/program files/blablabla/bla.exe"
os.execute('start "" "' .. path .. '"')
Code:
local path = "c:/program files/blablabla/bla.exe"
reaper.BR_Win32_ShellExecute("open", path, "", "", 1)
Code:
local directory = "c:/program files/blablabla"
local fileName = "bla.exe"
reaper.BR_Win32_ShellExecute("open", fileName, "", directory , 1)
|
Thank you so much Solger.
The last 2 solutions worked perfectly
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 01:32 AM.
|