Problem with Exec and ">"

Post your Gambas programming questions here.
Post Reply
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Problem with Exec and ">"

Post 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?
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Problem with Exec and ">"

Post 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.
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: Problem with Exec and ">"

Post 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
didier18
Posts: 38
Joined: Monday 19th December 2016 10:08pm

Re: Problem with Exec and ">"

Post by didier18 »

Hello

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

Have a good day.
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Problem with Exec and ">"

Post by cogier »

Thanks Didier, it was me who added the 'Example' to the Shell$ help file!
Post Reply