Thread: [Gambas-user] shell
Brought to you by:
gambas
From: Mike <mik...@we...> - 2008-09-02 11:16:40
|
Hi all I am trying to run the terminal with input from the gambas shell command. Looks like I have it wrong, any help please. SHELL "/home/mike/Desktop/Terminal espeak Hello" Regards all Mike |
From: Mike C. <mik...@y7...> - 2013-12-02 11:31:49
|
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. 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 |
From: Kende K. <ne...@fr...> - 2013-12-02 11:54:13
|
2013-12-02 12:17 keltezéssel, Mike Crean írta: > > 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. So the shell command is the following: sudo sh -c "echo out >/sys/class/gpio/gpio27/direction" (with '>') ? Try this: Exec ["sudo", "sh", "-c", "echo out >/sys/class/gpio/gpio27/direction"] Or use Gambas executable with root permission: File.Save("/sys/class/gpio/gpio27/direction", "out\n") > 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 Kendek |
From: Tobias B. <ta...@gm...> - 2013-12-02 11:56:02
|
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 |
From: MinnesotaJon <nic...@ac...> - 2013-12-02 16:08:49
|
Maybe I'm not understanding the problem, but "sudo" always wants a password, right? In which case you have to feed it a password with the Exec or Shell command. I'm not a shell script expert (just learning), but I assume that the string would look like this: Exec [system.shell, "sudo sh -c 'echo out /sys/class/gpio/gpio27/direction'<< EOF\nmypassword\nEOF"] where you have already dimensioned and set the value of "mypassword" in your code. If you have dimensioned a variable like "strShellResponseString", you will be able to display a response from sudo in your program, if the password is incorrect: Exec [system.shell, "sudo sh -c 'echo out /sys/class/gpio/gpio27/direction'<< EOF\nmypassword\nEOF"] TO strShellResponseString note: My additional code is a "here document" code block. "<<" feeds a command list to an interactive program or a command, like sudo. "EOF" means end-of-file, but it also terminates input from stdin. The newline escape code "\n" is needed before and after the password variable, to place the password where sudo expects it, after a linefeed from stdin, followed by another linefeed. And then the second "EOF" terminates this input, which allows sudo to evaluate the password and either execute the sh command, or give an error message if the password is wrong. No extra spaces in all of this, or they'll be interpreted as part of the code! -- View this message in context: http://gambas.8142.n7.nabble.com/shell-tp44500p44508.html Sent from the gambas-user mailing list archive at Nabble.com. |
From: Rolf-Werner E. <eil...@t-...> - 2013-12-02 17:14:22
|
You could allow a certain user to execute a command via the sudo system. I've got this here, one of the teachers is able to switch the internet on and off for students by applying a script. Normally, only the admin is allowed to change the filter chain... A Gambas front-end picks out the persons in the current class and feeds the script with their terminal data. Rolf Am 02.12.2013 17:08, schrieb MinnesotaJon: > Maybe I'm not understanding the problem, but "sudo" always wants a password, > right? In which case you have to feed it a password with the Exec or Shell > command. I'm not a shell script expert (just learning), but I assume that > the string would look like this: > > Exec [system.shell, "sudo sh -c 'echo out > /sys/class/gpio/gpio27/direction'<< EOF\nmypassword\nEOF"] > where you have already dimensioned and set the value of "mypassword" in your > code. > > If you have dimensioned a variable like "strShellResponseString", you will > be able to display a response from sudo in your program, if the password is > incorrect: > Exec [system.shell, "sudo sh -c 'echo out > /sys/class/gpio/gpio27/direction'<< EOF\nmypassword\nEOF"] TO > strShellResponseString > > note: My additional code is a "here document" code block. "<<" feeds a > command list to an interactive program or a command, like sudo. "EOF" means > end-of-file, but it also terminates input from stdin. The newline escape > code "\n" is needed before and after the password variable, to place the > password where sudo expects it, after a linefeed from stdin, followed by > another linefeed. And then the second "EOF" terminates this input, which > allows sudo to evaluate the password and either execute the sh command, or > give an error message if the password is wrong. No extra spaces in all of > this, or they'll be interpreted as part of the code! > > > > -- > View this message in context: http://gambas.8142.n7.nabble.com/shell-tp44500p44508.html > Sent from the gambas-user mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Rapidly troubleshoot problems before they affect your business. Most IT > organizations don't have a clear picture of how application performance > affects their revenue. With AppDynamics, you get 100% visibility into your > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! > http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk > _______________________________________________ > Gambas-user mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gambas-user > |
From: Ivan K. <iva...@fr...> - 2013-12-03 06:25:11
|
Hi Try Shell "echo 'mypassword' |sudo -S sh -c 'echo out /sys/class/gpio/gpio27/direction" Regards -----Ursprüngliche Nachricht----- Von: Mike Crean [mailto:mik...@y7...] Gesendet: Montag, 2. Dezember 2013 12:18 An: Mike Betreff: [Gambas-user] shell 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. 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 ---------------------------------------------------------------------------- -- Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk _______________________________________________ Gambas-user mailing list Gam...@li... https://lists.sourceforge.net/lists/listinfo/gambas-user |
From: Jussi L. <jus...@gm...> - 2013-12-03 08:07:58
|
> Try > Shell "echo 'mypassword' |sudo -S sh -c 'echo out > /sys/class/gpio/gpio27/direction" > Bad idea. Firstly, it supports only one password, which is stored as plain text. Secondly, if the password is variable it would need proper sanitation before entering it to shell. Jussi |
From: Mike C. <mik...@y7...> - 2013-12-03 11:25:30
|
Hey Ivan, thanks very much for that. I forgot all about the piping command. Regards Mike |
From: Mike C. <mik...@y7...> - 2017-04-24 09:51:15
|
If I run make from the terminal in a named directory make works as expected. Using Gambas 3.9.2 and run the command, shell "make" while in the named directory I get an error make: *** No targets specified and no makefile found. Stop The same error when I try to shell to a file containing #!/bin/sh and make.The file runs correctly when run from the named directory. The named directory permissions are set for anyone.This is on a Rpi3 running RaspbianAnyone have a fix for this please. Regards Mike |
From: Charlie <ch...@co...> - 2017-04-25 08:50:51
|
Can you post the 'Shell' code you are using. ----- Check out www.gambas.one -- View this message in context: http://gambas.8142.n7.nabble.com/shell-tp58793p58795.html Sent from the gambas-user mailing list archive at Nabble.com. |
From: Fabien B. <gam...@gm...> - 2017-04-25 14:57:08
|
??? 2017-04-25 10:52 GMT+02:00 Charlie <ch...@co...>: > Can you post the 'Shell' code you are using. > > > > ----- > Check out www.gambas.one > -- > View this message in context: http://gambas.8142.n7.nabble.com/shell-tp58793p58795.html > Sent from the gambas-user mailing list archive at Nabble.com. > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Gambas-user mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gambas-user -- Fabien Bodard |
From: Mike C. <mik...@y7...> - 2017-04-26 08:05:50
|
Thanks Fabien I have solved the problem. Regards Mike On Tuesday, 25 April 2017, 22:58, Fabien Bodard <gam...@gm...> wrote: ??? 2017-04-25 10:52 GMT+02:00 Charlie <ch...@co...>: > Can you post the 'Shell' code you are using. > > > > ----- > Check out www.gambas.one > -- > View this message in context: http://gambas.8142.n7.nabble.com/shell-tp58793p58795.html > Sent from the gambas-user mailing list archive at Nabble.com. > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Gambas-user mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gambas-user -- Fabien Bodard ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Gambas-user mailing list Gam...@li... https://lists.sourceforge.net/lists/listinfo/gambas-user |
From: Szenográdi N. P. <sev...@gm...> - 2008-09-02 11:33:33
|
Hi, this is working fine: PUBLIC SUB Form_Open() SHELL "espeak Hello" END regards, Sevoir 2008. 09. 2, kedd keltezéssel 19.16-kor Mike ezt írta: > Hi all > > > > I am trying to run the terminal with input from the gambas shell command. > Looks like I have it wrong, any help please. > > > > SHELL "/home/mike/Desktop/Terminal espeak Hello" > > > > Regards all > > Mike > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Gambas-user mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gambas-user |