[Gambas-user] shell
Tobias Boege
taboege at ...626...
Mon Dec 2 12:55:31 CET 2013
On Mon, 02 Dec 2013, Mike Crean wrote:
>
> Hey boys, I am trying to emulate the terminal string sudo sh -c
> 'echo out /sys/class/gpio/gpio27/direction' (works OK in terminal, on
> BBB wheezy arm lxde) I run this from gambas3.5.90 Exec [system.shell,
> "sudo sh -c 'echo out /sys/class/gpio/gpio27/direction'"]
> and get an error /bin/sh: 0: Can't open sudo sh -c 'echo out
> /sys/class/gpio/gpio27/direction' any help please.
>
If you write Exec [System.Shell, "sudo sh -c ..."], then the second string
is the first and only argument to System.Shell. At least on my system, the
default shell tries to execute that program.
However, "sudo sh -c ..." is normally not a program. "sudo" is a program,
"sh" is one and "-c" and "..." are arguments but the whole string is not a
program name. You have to put them all in separate entries in the Exec
array: Exec [System.Shell, "sudo", "sh", "-c", "..."].
> I
> have also tried shell "sudo sh -c 'echo out
> /sys/class/gpio/gpio27/direction'" this runs with out error and
> but will not change data in the direction file. It stays at the old
> value of "in".
>
> If
> I run it from a terminal the string works fine.
>
> Thanks
> in advance
> Mike
Are you really sure that the *same* command works in a terminal? I mean:
$ sudo sh -c 'echo out /sys/class/gpio/gpio27/direction'
All the echo's I have seen so far will *not* write "out" to
/sys/class/gpio/gpio27/direction if called that way. They will just print
"out /sys/class/gpio/gpio27/direction" literally. You may need to redirect
"out" to the file like in
$ sudo sh -c 'echo out >/sys/class/gpio/gpio27/direction'
Regards,
Tobi
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
More information about the User
mailing list