Old 06-19-2018, 07:40 AM   #1
atonalist
Human being with feelings
 
Join Date: May 2018
Location: Stony Brook, New York
Posts: 3
Default 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?
atonalist is offline   Reply With Quote
Old 06-19-2018, 09:14 AM   #2
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,878
Default

- 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.
__________________
Currently working away from home; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is online now   Reply With Quote
Old 06-19-2018, 09:26 AM   #3
mespotine
Human being with feelings
 
Join Date: May 2017
Posts: 230
Default

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.
mespotine is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:37 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.