Problem with Exec and ">"

Post

Posted
Rating:
#1 (In Topic #112)
Avatar
Regular
stevedee is in the usergroup ‘Regular’
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:-

Code (gambas)

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

Code (gambas)

  1. 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?
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Guru
cogier is in the usergroup ‘Guru’
 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.
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Regular
stevedee is in the usergroup ‘Regular’

cogier said

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: /doc/shellexec - Gambas Documentation
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
didier18 is in the usergroup ‘Regular’
Hello

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

Have a good day.

Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Guru
cogier is in the usergroup ‘Guru’
 Thanks Didier, it was me who added the 'Example' to the Shell$ help file!
Online now: No Back to the top
1 guest and 0 members have just viewed this.