Old 09-10-2017, 01:57 AM   #1
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default 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!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 09-10-2017, 02:09 AM   #2
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

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)
cfillion is offline   Reply With Quote
Old 09-10-2017, 02:42 AM   #3
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

Hmm, nope... still doesn't do anything! :S
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 09-10-2017, 02:48 AM   #4
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

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.
cfillion is offline   Reply With Quote
Old 09-10-2017, 02:53 AM   #5
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

I'll check when I am back. Have to go now...

Thank you so much once more for the help!!!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 09-10-2017, 08:10 AM   #6
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

Return is 0 and path is "C:\Users\My Daw\Desktop"

PS.. Oh I see.. Maybe I have to escape every \ with a \
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 09-10-2017, 08:16 AM   #7
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

Hmm.. Nope.. it wasn't that...
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 09-10-2017, 08:21 AM   #8
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

Quote:
Originally Posted by cfillion View Post
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?
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 09-10-2017, 01:48 PM   #9
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

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.
cfillion is offline   Reply With Quote
Old 09-11-2017, 06:39 AM   #10
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

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!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 06-05-2018, 12:45 PM   #11
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,900
Default

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.
X-Raym is offline   Reply With Quote
Old 06-05-2018, 12:53 PM   #12
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

If you just use / for path separators it should work on Windows, Mac, and Linux.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 06-05-2018, 12:57 PM   #13
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Quote:
Originally Posted by X-Raym View Post
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".
cfillion is offline   Reply With Quote
Old 06-05-2018, 12:58 PM   #14
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,900
Default

@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.
X-Raym is offline   Reply With Quote
Old 06-05-2018, 01:04 PM   #15
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Quote:
Originally Posted by X-Raym View Post
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'
cfillion is offline   Reply With Quote
Old 06-05-2018, 01:04 PM   #16
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,900
Default

Quote:
Otherwise on macOS the program doing a similar job is "open"
This doesn't work for 'echo' :S


Any other idea ?
X-Raym is offline   Reply With Quote
Old 06-05-2018, 01:07 PM   #17
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,900
Default

@cfillion
Code:
reaper.ExecProcess("/bin/sh -c echo 1")
reaper.ExecProcess("/bin/sh -c echo '1'")
Both return
Code:
0\n\n

There is some progress though as previous code return error -999.
X-Raym is offline   Reply With Quote
Old 06-05-2018, 01:09 PM   #18
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

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.
cfillion is offline   Reply With Quote
Old 06-05-2018, 01:11 PM   #19
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,900
Default

@cfillion
Oh yes ok, thanks ! Easy to get lost with all this escaping ^^


Though, it returns


Code:
0\n1\n1

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 ?
X-Raym is offline   Reply With Quote
Old 06-05-2018, 01:13 PM   #20
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Quote:
Originally Posted by X-Raym View Post
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.
cfillion is offline   Reply With Quote
Old 06-05-2018, 01:14 PM   #21
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,900
Default

@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 !
X-Raym is offline   Reply With Quote
Old 07-03-2018, 11:59 AM   #22
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,067
Default

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') ...
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 07-03-2018, 12:12 PM   #23
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,900
Default

@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.
X-Raym is offline   Reply With Quote
Old 07-03-2018, 04:46 PM   #24
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,067
Default

Thanks X-Raym! Will try that
The LUA guide looks very promissing as well!
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 07-03-2018, 06:35 PM   #25
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by X-Raym View Post
I think one of the best website (easy to read) website for lua basics is : https://www.tutorialspoint.com/lua/index.htm
Definitely better than the X-Raym tutorials. Those videos are so bad that I actually forgot how to program after watching them. :P
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 07-04-2018, 01:33 AM   #26
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,900
Default

@Lokasenna
Making bad video tutorials is my plan to annihilate the concurence. busted !
X-Raym is offline   Reply With Quote
Old 04-06-2020, 08:37 AM   #27
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

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!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 04-06-2020, 10:04 AM   #28
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

maybe try this?...from ReaScript API,
boolean reaper.CF_LocateInExplorer(string file)
Select the given file in explorer/finder.
Edgemeal is offline   Reply With Quote
Old 04-06-2020, 12:31 PM   #29
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

Oh, I didn't know this API existed! Nice!
Thanks Edgemeal!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma 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 07:17 AM.


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