Problem with Exec and ">"

Post Reply
stevedee
Posts: 36
Joined: Monday 20th March 2017 6:06pm

Problem with Exec and ">"

Post by stevedee » Monday 20th March 2017 6:16pm

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: 102
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Problem with Exec and ">"

Post by cogier » Tuesday 21st March 2017 8:39am

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.

stevedee
Posts: 36
Joined: Monday 20th March 2017 6:06pm

Re: Problem with Exec and ">"

Post by stevedee » Tuesday 21st March 2017 2:10pm

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: 16
Joined: Monday 19th December 2016 10:08pm

Re: Problem with Exec and ">"

Post by didier18 » Tuesday 21st March 2017 2:50pm

Hello

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

Have a good day.

User avatar
cogier
Site Admin
Posts: 102
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Problem with Exec and ">"

Post by cogier » Tuesday 21st March 2017 3:10pm

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

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest