Page 1 of 1

Scripting systemcommand argument passed badly

Posted: Tue Apr 26, 2016 4:14 pm
by iamchrislaurie
The following command works from the command line (using Linux):

audtool set-volume $(('audtool get-volume' - 5))

I cannot get that to script. I have tried many variants of the following

systemcommand:audtool arg1:"set-volume" arg2:"$(('audtool get-volume' - 5))"

Is there some syntax trick to getting the exact line passed to the OS?

Re: Scripting systemcommand argument passed badly

Posted: Tue Apr 26, 2016 4:29 pm
by janosvitok
Maybe you need to call bash to do the parameter expansion.

systemcommand:bash arg1: "audtool" arg2:"set-volume" arg3:"$(('audtool get-volume' - 5))"

Re: Scripting systemcommand argument passed badly

Posted: Tue Apr 26, 2016 4:44 pm
by iamchrislaurie
Thank you for the response Jano!

Unfortunately that did not work.

Re: Scripting systemcommand argument passed badly

Posted: Tue Apr 26, 2016 6:32 pm
by sbenejam
This is a command that calls a python test script that I use: systemcommand:python-script.py arg:dspdfviewer arg:P
Maybe it could help.

Re: Scripting systemcommand argument passed badly

Posted: Tue Apr 26, 2016 6:59 pm
by plugz
Try this one:

Code: Select all

systemcommand:bash arg1:"-c" arg2:"audtool set-volume $(($(audtool get-volume) - 5))"

Re: Scripting systemcommand argument passed badly

Posted: Wed Apr 27, 2016 8:46 am
by mcallegari
I have written an example in the documentation, so where did you guys read arg1, arg2, etc ?

http://www.qlcplus.org/docs/scripteditor.html

Code: Select all

systemcommand:/usr/bin/vlc arg:-f arg:/home/user/video.mp4 // plays my video with VLC in fullscreen
most likely this is what you want

Code: Select all

systemcommand:audtool arg:set-volume arg:"$(('audtool get-volume' - 5))"
By the way, this looks more like a usage question rather than a issue report...

Re: Scripting systemcommand argument passed badly

Posted: Wed Apr 27, 2016 9:25 am
by plugz
mcallegari wrote:I have written an example in the documentation, so where did you guys read arg1, arg2, etc ?
You're right, arg1 arg2 etc is useless.

But it works. You can also replace "arg" with "hi" or "hello", it will work too. Should a github issue be opened for this ?

Code: Select all

systemcommand:audtool arg:set-volume arg:"$(('audtool get-volume' - 5))"
This does not work, because

Code: Select all

$((`audtool get-volume`))
is something that has to be interpreted by bash. QLC+ does not run processes through bash commands. Also, I think the simple quote around

Code: Select all

audtool get-volume
are a miscopy, they should be backquotes. But this is another issue.
By the way, this looks more like a usage question rather than a issue report...
Maybe.



Please try this one:

Code: Select all

systemcommand:bash arg:-c arg:"audtool set-volume $(($(audtool get-volume) - 5))"

Re: Scripting systemcommand argument passed badly

Posted: Wed Apr 27, 2016 9:36 am
by mcallegari
But it works. You can also replace "arg" with "hi" or "hello", it will work too. Should a github issue be opened for this ?
Ugh...yes please

Then have a look at #843 please :)
This does not work, because

Code: Select all

$((`audtool get-volume`))
is something that has to be interpreted by bash. QLC+ does not run processes through bash commands. Also, I think the simple quote around
Right. I'm wondering if the QProcess class can actually work like a proper shell. I'll check the docs when I have some time

Re: Scripting systemcommand argument passed badly

Posted: Wed Apr 27, 2016 9:52 am
by plugz
mcallegari wrote: Right. I'm wondering if the QProcess class can actually work like a proper shell. I'll check the docs when I have some time
No it can't. It's not a shell command interpreter. It simply runs a process.
And I think it's fine like this. Users can still use "bash -c" to run shell commands. Or even write the script in an external .sh file.

Re: Scripting systemcommand argument passed badly

Posted: Wed Apr 27, 2016 9:52 am
by mcallegari
plugz wrote:
mcallegari wrote: Right. I'm wondering if the QProcess class can actually work like a proper shell. I'll check the docs when I have some time
No it can't. It's not a shell command interpreter. It simply runs a process.
And I think it's fine like this. Users can still use "bash -c" to run shell commands. Or even write the script in an external .sh file.
Actually, you can pass the system environment to it:
http://doc.qt.io/qt-5/qprocess.html#set ... nvironment

In any case I agree regarding a shell script.
I would do something like

Code: Select all

setVolume.sh 5
setVolume.sh -5

Re: Scripting systemcommand argument passed badly

Posted: Thu Apr 28, 2016 7:32 am
by iamchrislaurie
That is what I did in the end I created a shell file. I could not get the bash -c to work. This solution probably won't work in Windows.

One thing that would work for this use case is if the scripting allowed for the interim storage of the result of a systemcommand call - some like this

%v = systemcommand:audtool arg1:get-volume
systemcommand:audtool arg1:set-volume arg2:%v - 1

Not sure about how the syntax will work but that would give us the start of the capability to read and set dmx channel values via these variables.

Re: Scripting systemcommand argument passed badly

Posted: Sun Jul 21, 2019 6:48 am
by Stringfamily
systemcommand:/bin/sh arg:/home/pi/PP-QLC-Lights/ShowVoxON.sh // copies show file with vocals to correct location


This is what in a few different versions I use to change audio files used in a show... works great. Attach it to a button and OSC command.