Scripting systemcommand argument passed badly

Ask a question about the usage of QLC+ with the Linux operating system
iamchrislaurie
Posts: 54
Joined: Mon Apr 27, 2015 11:27 am
Real Name: Chris Laurie

Scripting systemcommand argument passed badly

Post by iamchrislaurie » Tue Apr 26, 2016 4:14 pm

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?

janosvitok
Posts: 830
Joined: Mon Apr 13, 2015 7:05 am
Location: Bratislava, Slovakia
Real Name: Jano Svitok
Contact:

Re: Scripting systemcommand argument passed badly

Post by janosvitok » Tue Apr 26, 2016 4:29 pm

Maybe you need to call bash to do the parameter expansion.

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

iamchrislaurie
Posts: 54
Joined: Mon Apr 27, 2015 11:27 am
Real Name: Chris Laurie

Re: Scripting systemcommand argument passed badly

Post by iamchrislaurie » Tue Apr 26, 2016 4:44 pm

Thank you for the response Jano!

Unfortunately that did not work.

User avatar
sbenejam
Posts: 108
Joined: Sun Apr 12, 2015 6:28 pm
Real Name: Santiago Benejam Torres
Contact:

Re: Scripting systemcommand argument passed badly

Post by sbenejam » Tue Apr 26, 2016 6:32 pm

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.

plugz
Posts: 637
Joined: Sun Apr 12, 2015 6:30 pm
Real Name: David

Re: Scripting systemcommand argument passed badly

Post by plugz » Tue Apr 26, 2016 6:59 pm

Try this one:

Code: Select all

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

User avatar
mcallegari
Posts: 1866
Joined: Sun Apr 12, 2015 9:09 am
Location: Italy
Real Name: Massimo Callegari
Contact:

Re: Scripting systemcommand argument passed badly

Post by mcallegari » Wed Apr 27, 2016 8:46 am

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...

plugz
Posts: 637
Joined: Sun Apr 12, 2015 6:30 pm
Real Name: David

Re: Scripting systemcommand argument passed badly

Post by plugz » Wed Apr 27, 2016 9:25 am

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))"

User avatar
mcallegari
Posts: 1866
Joined: Sun Apr 12, 2015 9:09 am
Location: Italy
Real Name: Massimo Callegari
Contact:

Re: Scripting systemcommand argument passed badly

Post by mcallegari » Wed Apr 27, 2016 9:36 am

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

plugz
Posts: 637
Joined: Sun Apr 12, 2015 6:30 pm
Real Name: David

Re: Scripting systemcommand argument passed badly

Post by plugz » Wed Apr 27, 2016 9:52 am

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.

User avatar
mcallegari
Posts: 1866
Joined: Sun Apr 12, 2015 9:09 am
Location: Italy
Real Name: Massimo Callegari
Contact:

Re: Scripting systemcommand argument passed badly

Post by mcallegari » Wed Apr 27, 2016 9:52 am

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

Post Reply