Page 1 of 1

Problem with Exec and ">"

Posted: Monday 20th March 2017 6:16pm
by stevedee
I sometimes have problems with tricky Linux commands when using either the Gambas Exec or Shell commands. Its usually Shell that gives me a headache, but for this Linux command:-

find "/home/pi/Music" -type f -iname "*.mp3" -o -iname "*.ogg" -o -iname "*.wma" > "/home/pi/Music/playlist"

...which works in a terminal, I can successfully use Shell like this in Gambas:-
Shell "find /home/pi/Music -type f -iname *.mp3 -o -iname *.ogg -o -iname *.wma > /home/pi/Music/playlist"
...but I can't get the syntax right using Exec. This works:-
Exec ["find", "/home/pi/Music", "-type", "f", "-iname", "*.mp3", "-o", "-name", "*.ogg", "-o", "-name", "*.wma"] to strTemp
...but changing the last bit to:-

"*wma",">", "/home/pi/Music/playlist"]

...gives me an error: "find: paths must precede expression: >"

So it looks like I have a problem with the re-direct operator ">"

Can someone put me out of my misery?

Re: Problem with Exec and ">"

Posted: Tuesday 21st March 2017 8:39am
by cogier
The redirect '>' is a terminal command. It can only be used with Shell. When you use Exec there is no terminal so '>' has no meaning. The Pipe '|' command is another example.

Re: Problem with Exec and ">"

Posted: Tuesday 21st March 2017 2:10pm
by stevedee
cogier wrote: Tuesday 21st March 2017 8:39am The redirect '>' is a terminal command. It can only be used with Shell...
Thanks cogier.

I should have gone through the documentation more carefully, as its mentioned here: http://gambaswiki.org/wiki/doc/shellexec

Re: Problem with Exec and ">"

Posted: Tuesday 21st March 2017 2:50pm
by didier18
Hello

In addition to information, there is also this Shell$ (in English)...

Have a good day.

Re: Problem with Exec and ">"

Posted: Tuesday 21st March 2017 3:10pm
by cogier
Thanks Didier, it was me who added the 'Example' to the Shell$ help file!