|
|
|
09-10-2017, 01:57 AM
|
#1
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,458
|
reaper.ExecProcess . How?
Hello!
In a few words, this works:
Code:
os.execute('start "" "'..path..'"')
But this doesn't:
Code:
reaper.ExecProcess('start "" "'..path..'"', 0)
Any ideas?
Thanks!
|
|
|
09-10-2017, 02:09 AM
|
#2
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,968
|
start is a cmd.exe command, it's not a standalone program. Try this:
Code:
reaper.ExecProcess('cmd.exe /C start "" "'..path..'"', 0)
(of course this won't work on macOS and Linux, and mind the risk of command injection if variable `path` is arbitrary)
|
|
|
09-10-2017, 02:42 AM
|
#3
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,458
|
Hmm, nope... still doesn't do anything! :S
|
|
|
09-10-2017, 02:48 AM
|
#4
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,968
|
What does `path` contains and what does ExecProcess returns (it should be non-nil)?
This works here (opens C:\ in explorer.exe and returns "0\n"):
Code:
local path = 'C:\\'
reaper.ExecProcess('cmd.exe /C start "" "'..path..'"', 0)
Last edited by cfillion; 09-10-2017 at 03:00 AM.
|
|
|
09-10-2017, 02:53 AM
|
#5
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,458
|
I'll check when I am back. Have to go now...
Thank you so much once more for the help!!!
|
|
|
09-10-2017, 08:10 AM
|
#6
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,458
|
Return is 0 and path is "C:\Users\My Daw\Desktop"
PS.. Oh I see.. Maybe I have to escape every \ with a \
|
|
|
09-10-2017, 08:16 AM
|
#7
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,458
|
Hmm.. Nope.. it wasn't that...
|
|
|
09-10-2017, 08:21 AM
|
#8
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,458
|
Quote:
Originally Posted by cfillion
What does `path` contains and what does ExecProcess returns (it should be non-nil)?
This works here (opens C:\ in explorer.exe and returns "0\n"):
Code:
local path = 'C:\\'
reaper.ExecProcess('cmd.exe /C start "" "'..path..'"', 0)
|
This worked, then I tried some things with my code (like escaping \ with \) and now it stopped working! :S Bug?
|
|
|
09-10-2017, 01:48 PM
|
#9
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,968
|
One thing you can try is:
Code:
reaper.ShowConsoleMsg('cmd.exe /C start "" "'..path..'"\n')
...and check for oddities in the generated command line. Also try it directly in cmd.exe to bypass any risk of a bug in REAPER or your Lua script.
Last edited by cfillion; 09-10-2017 at 01:56 PM.
|
|
|
09-11-2017, 06:39 AM
|
#10
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,458
|
Today it seems to work (I had to escape each \ with a \)
But, what I found is that if you enter a few times invalid arguments to reaper.ExecProcess then it stops working (this is what happened to me yesterday). A Reaper restart does not solve the problem!
|
|
|
06-05-2018, 12:45 PM
|
#11
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,900
|
Quote:
Originally Posted by cfillion
of course this won't work on macOS and Linux
|
What would be the macOS equivalent then ? Not cmd.exe obviously.
EDIT: I found this info : https://forum.cockos.com/showpost.ph...37&postcount=6 but isnt the terminal path.
|
|
|
06-05-2018, 12:53 PM
|
#12
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
If you just use / for path separators it should work on Windows, Mac, and Linux.
|
|
|
06-05-2018, 12:57 PM
|
#13
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,968
|
Quote:
Originally Posted by X-Raym
What would be the macOS equivalent then ? Not cmd.exe obviously.
|
To the start command (open a file or URL with the default application)? reaper.CF_ShellExecute.
Otherwise on macOS the program doing a similar job is "open" and on most Linux installations it is "xdg-open".
|
|
|
06-05-2018, 12:58 PM
|
#14
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,900
|
@Lokasenna
I have a big command with some echo command in it.
I'm trying to see if ExecProcess can take care of this echo call, so I can just map my big command to it.
How would you use echo within ExecProcess ?
My command is a succession of CLI program call followed by ' & ' (or '; ' on Mac), and some of this & or ; are followed by echo Something.
|
|
|
06-05-2018, 01:04 PM
|
#15
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,968
|
Quote:
Originally Posted by X-Raym
My command is a succession of CLI program call followed by ' & ' (or '; ' on Mac), and some of this & or ; are followed by echo Something.
|
Code:
/bin/sh -c 'command_a; command_b; command_c'
|
|
|
06-05-2018, 01:04 PM
|
#16
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,900
|
Quote:
Otherwise on macOS the program doing a similar job is "open"
|
This doesn't work for 'echo' :S
Any other idea ?
|
|
|
06-05-2018, 01:07 PM
|
#17
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,900
|
@cfillion
Code:
reaper.ExecProcess("/bin/sh -c echo 1")
reaper.ExecProcess("/bin/sh -c echo '1'")
Both return
There is some progress though as previous code return error -999.
|
|
|
06-05-2018, 01:09 PM
|
#18
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,968
|
The whole command line must be in a single argument for the -c option. So you'll need either quotes or to escape the spaces. Perhaps you could run bwfmetaedit directly with ExecProcess instead? (I don't remember if you tried that before)
Code:
reaper.ExecProcess("/bin/sh -c 'echo 1'", 0)
Last edited by cfillion; 06-05-2018 at 01:22 PM.
|
|
|
06-05-2018, 01:11 PM
|
#19
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,900
|
@cfillion
Oh yes ok, thanks ! Easy to get lost with all this escaping ^^
Though, it returns
How come ?
I guess I should only take care of the second line ?
EDIT: I guess these extra characters comme from ExecProcess which wrap the answer into an status code and a break line ?
|
|
|
06-05-2018, 01:13 PM
|
#20
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,968
|
Quote:
Originally Posted by X-Raym
EDIT: I guess these extra characters comme from ExecProcess which wrap the answer into an status code and a break line ?
|
Yup. REAPER puts the exit code of the process in first line (0 means success). Everything else is the actual output.
|
|
|
06-05-2018, 01:14 PM
|
#21
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,900
|
@cfillion
Understood.
I'll experiment this VS os.execute I currently use and see it it works as good for my case :P
Many thanks !
|
|
|
07-03-2018, 11:59 AM
|
#22
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,067
|
Thanks guys, awesome discussion.
I have a variable called loopStartTime. How can I use it in the command line arguments?
That's the command:
Code:
reaper.ExecProcess('/Applications/ffmpeg/ffmpeg -ss loopStartTime') ...
|
|
|
07-03-2018, 12:12 PM
|
#23
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,900
|
@Stevie
Just concatanate the string and the variable using ".." operator
Code:
reaper.ExecProcess('/Applications/ffmpeg/ffmpeg -ss ' .. loopStartTime)
I think one of the best website (easy to read) website for lua basics is : https://www.tutorialspoint.com/lua/index.htm
Last edited by X-Raym; 07-03-2018 at 04:49 PM.
|
|
|
07-03-2018, 04:46 PM
|
#24
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,067
|
Thanks X-Raym! Will try that
The LUA guide looks very promissing as well!
|
|
|
07-03-2018, 06:35 PM
|
#25
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Quote:
Originally Posted by X-Raym
|
Definitely better than the X-Raym tutorials. Those videos are so bad that I actually forgot how to program after watching them. :P
|
|
|
07-04-2018, 01:33 AM
|
#26
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,900
|
@Lokasenna
Making bad video tutorials is my plan to annihilate the concurence. busted !
|
|
|
04-06-2020, 08:37 AM
|
#27
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,458
|
What is the equivalent of this for Linux/OSX? :
Code:
(Windows)
reaper.ExecProcess('explorer.exe /e,/select,"' .. Path .. '"', -1)
Is this correct?
Code:
reaper.ExecProcess('/usr/bin/open -R "' .. Path .. '"', -1)
I want to open the file explorer with the file selected.
Thanks!
|
|
|
04-06-2020, 10:04 AM
|
#28
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
|
maybe try this?...from ReaScript API,
boolean reaper.CF_LocateInExplorer(string file)
Select the given file in explorer/finder.
|
|
|
04-06-2020, 12:31 PM
|
#29
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,458
|
Oh, I didn't know this API existed! Nice!
Thanks Edgemeal!
|
|
|
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 12:25 AM.
|