Re: shell() question
The shell function inherits its environment from LC so there's no issue here. You can also use open process for update, write to it then read from it. The elevated version of open process prompts for authentication and then runs the process as administrator. It uses system support for UI based prompting - it works well on windows and Mac (which have builtin support), Linux support is a little more patchy as it requires gksu (iirc) to work. Sent from my iPhone On 23 Jul 2015, at 08:28, David Bovill david@viral.academy wrote: Well I found one - though I'm not sure it is strictly legal: put some text into $LIVECODEVAR put shell (echo $LIVECODEVAR | shellThing -q) which is great. I don't think this pollutes the environment, as AFAIK shell() is in it's own space (like opening a tab in the terminal) - but are there any issues? I'd like to try writing to a process - as I think you can do the equivalent of shell with a commandline tool. Does anyone have an example - and can explain elevated process - the docs are a bit sparse. Is elevated like sudo? On 23 July 2015 at 08:18, David Bovill david@viral.academy wrote: I'm wandering if there is a neat trick to pass data to a shell command via STDIN. The only thing I know how to do is either: 1. Write a bash script that accepts an input param and call this 2. put shell (echo 'some text' | shellThing) Is there a neater way? ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: shell() question
On the contrary, open process can be used in a non-blocking way - although you do need to poll using read until empty (which returns all available data at that point). (The read from process command could do with a callback form really - like read from socket has). I've done this before - you have a controlling process which opens other processes, then every polling interval (100ms say) it does read from empty on all of them then processes any data which comes from them. When a process returns eof from the read it means the process has finished. Sent from my iPhone On 23 Jul 2015, at 13:57, David Bovill david@viral.academy wrote: Thanks Mark. I'm going to give open process for update a spin. Is this something that you would consider robust enough to be used in a long running server type context? So we can have a Livecode server communicating with these processes and serving out processed results over sockets to a web server for instance - or is this something we should only consider for short run - get the process up and running then shut it down interactions? I guess it is a blocking operation... On 23 July 2015 at 13:33, Mark Waddingham m...@livecode.com wrote: The shell function inherits its environment from LC so there's no issue here. You can also use open process for update, write to it then read from it. The elevated version of open process prompts for authentication and then runs the process as administrator. It uses system support for UI based prompting - it works well on windows and Mac (which have builtin support), Linux support is a little more patchy as it requires gksu (iirc) to work. Sent from my iPhone On 23 Jul 2015, at 08:28, David Bovill david@viral.academy wrote: Well I found one - though I'm not sure it is strictly legal: put some text into $LIVECODEVAR put shell (echo $LIVECODEVAR | shellThing -q) which is great. I don't think this pollutes the environment, as AFAIK shell() is in it's own space (like opening a tab in the terminal) - but are there any issues? I'd like to try writing to a process - as I think you can do the equivalent of shell with a commandline tool. Does anyone have an example - and can explain elevated process - the docs are a bit sparse. Is elevated like sudo? On 23 July 2015 at 08:18, David Bovill david@viral.academy wrote: I'm wandering if there is a neat trick to pass data to a shell command via STDIN. The only thing I know how to do is either: 1. Write a bash script that accepts an input param and call this 2. put shell (echo 'some text' | shellThing) Is there a neater way? ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: shell() question
Thanks Mark. I'm going to give open process for update a spin. Is this something that you would consider robust enough to be used in a long running server type context? So we can have a Livecode server communicating with these processes and serving out processed results over sockets to a web server for instance - or is this something we should only consider for short run - get the process up and running then shut it down interactions? I guess it is a blocking operation... On 23 July 2015 at 13:33, Mark Waddingham m...@livecode.com wrote: The shell function inherits its environment from LC so there's no issue here. You can also use open process for update, write to it then read from it. The elevated version of open process prompts for authentication and then runs the process as administrator. It uses system support for UI based prompting - it works well on windows and Mac (which have builtin support), Linux support is a little more patchy as it requires gksu (iirc) to work. Sent from my iPhone On 23 Jul 2015, at 08:28, David Bovill david@viral.academy wrote: Well I found one - though I'm not sure it is strictly legal: put some text into $LIVECODEVAR put shell (echo $LIVECODEVAR | shellThing -q) which is great. I don't think this pollutes the environment, as AFAIK shell() is in it's own space (like opening a tab in the terminal) - but are there any issues? I'd like to try writing to a process - as I think you can do the equivalent of shell with a commandline tool. Does anyone have an example - and can explain elevated process - the docs are a bit sparse. Is elevated like sudo? On 23 July 2015 at 08:18, David Bovill david@viral.academy wrote: I'm wandering if there is a neat trick to pass data to a shell command via STDIN. The only thing I know how to do is either: 1. Write a bash script that accepts an input param and call this 2. put shell (echo 'some text' | shellThing) Is there a neater way? ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: shell() question
Well I found one - though I'm not sure it is strictly legal: put some text into $LIVECODEVAR put shell (echo $LIVECODEVAR | shellThing -q) which is great. I don't think this pollutes the environment, as AFAIK shell() is in it's own space (like opening a tab in the terminal) - but are there any issues? I'd like to try writing to a process - as I think you can do the equivalent of shell with a commandline tool. Does anyone have an example - and can explain elevated process - the docs are a bit sparse. Is elevated like sudo? On 23 July 2015 at 08:18, David Bovill david@viral.academy wrote: I'm wandering if there is a neat trick to pass data to a shell command via STDIN. The only thing I know how to do is either: 1. Write a bash script that accepts an input param and call this 2. put shell (echo 'some text' | shellThing) Is there a neater way? ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Shell question
OK, I got this working. In order to get the correct linefeed characters for Unix, I had to open the output file in binary mode. Once I did that, everything worked fine. Pete On Sun, Jan 8, 2012 at 11:00 PM, Pete p...@mollysrevenge.com wrote: The command is in a variable, eg put shell(myCommand) into myResult. I'm thinking it's something other than that though since even if I type the command directly into Terminal with the stdin redirection, no output is produced. sqlite3 has a .echo command which prints all the commands to stdin. If I put that into the stdin file, what gets displayed is portions of each command with no line breaks between them. It sure feels like some sort of carriage return problem! Pete On Sun, Jan 8, 2012 at 7:31 PM, Mark Wieder mwie...@ahsoftware.netwrote: Pete- Sunday, January 8, 2012, 6:54:44 PM, you wrote: Those commands all work fine when typed into the program by me but nothing is written to the output file if I redirect stdin to a file that contains them. Ah. In that case, are you putting quotes around the shell command? Works here for me. put shell(myprog /Users/Pete/myfile.txt) into myResult -- -Mark Wieder mwie...@ahsoftware.net ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode -- Pete Molly's Revenge http://www.mollysrevenge.com -- Pete Molly's Revenge http://www.mollysrevenge.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Shell question
Ah. The beauty of Livecode's OS X/Unix return substitutions. OS X is unix. Kind of. Until you shell out from Livecode. On Mon, Jan 9, 2012 at 5:42 PM, Pete p...@mollysrevenge.com wrote: OK, I got this working. In order to get the correct linefeed characters for Unix, ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Shell question
Pete- I've read through this a couple of times now trying to parse what you're trying to do. Here's my guess: you'd like to set up a text file of responses to prompts from the myProg program, which would be processed at the time myProg wants more input. If so, you should check out the expect command. -- -Mark Wieder mwie...@ahsoftware.net ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Shell question
Pete, Is your set-up on the on-rev servers? Mike --- On Sun, 1/8/12, Pete p...@mollysrevenge.com wrote: From: Pete p...@mollysrevenge.com Subject: Shell question To: How to use LiveCode use-livecode@lists.runrev.com Date: Sunday, January 8, 2012, 7:52 PM I suspect this is more of a Unix question than LC but here goes. I'm issuing a shell command to run a program and redirect its stdin to a file, so something like put shell(myprog /Users/Pete/myfile.txt) into myResult The Stdin file contains 3 or 4 lines that are valid input to myProg, one of which writes some output to another file. When I execute the shell command from LC or type the command into Terminal, the output file does not created, but I get no errors reported. If I run myProg from Terminal and type the commands individually, the output file is created correctly. I've checked the path to the stdin file over and over and I'm sure it's correct. The stdin file was created using TesxtEdit, read in to myLC script, had a couple of things replaced in it and written out again from LC I'm suspecting carriage return issues? -- Pete Molly's Revenge http://www.mollysrevenge.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Shell question
Hi Mark, The program in question is sqlite3. I'm trying to give it commands to export an sqlite table in the form of INSERT commands. The program is run by typeing: sqlite3 dbname after it has started I need to feed it the following commands: .mode sql .output outputfilename SELECT whatever; .exit Those commands all work fine when typed into the program by me but nothing is written to the output file if I redirect stdin to a file that contains them. Seems like that ought to work but I'll try the spawn/send/expect commands and see if I can get them to work any better. Pete On Sun, Jan 8, 2012 at 6:06 PM, Mark Wieder mwie...@ahsoftware.net wrote: Pete- I've read through this a couple of times now trying to parse what you're trying to do. Here's my guess: you'd like to set up a text file of responses to prompts from the myProg program, which would be processed at the time myProg wants more input. If so, you should check out the expect command. -- -Mark Wieder mwie...@ahsoftware.net ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode -- Pete Molly's Revenge http://www.mollysrevenge.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Shell question
Mi Michael, This is running on my desktop (OS X) Pete On Sun, Jan 8, 2012 at 6:24 PM, Michael Kann mikek...@yahoo.com wrote: Pete, Is your set-up on the on-rev servers? Mike --- On Sun, 1/8/12, Pete p...@mollysrevenge.com wrote: From: Pete p...@mollysrevenge.com Subject: Shell question To: How to use LiveCode use-livecode@lists.runrev.com Date: Sunday, January 8, 2012, 7:52 PM I suspect this is more of a Unix question than LC but here goes. I'm issuing a shell command to run a program and redirect its stdin to a file, so something like put shell(myprog /Users/Pete/myfile.txt) into myResult The Stdin file contains 3 or 4 lines that are valid input to myProg, one of which writes some output to another file. When I execute the shell command from LC or type the command into Terminal, the output file does not created, but I get no errors reported. If I run myProg from Terminal and type the commands individually, the output file is created correctly. I've checked the path to the stdin file over and over and I'm sure it's correct. The stdin file was created using TesxtEdit, read in to myLC script, had a couple of things replaced in it and written out again from LC I'm suspecting carriage return issues? -- Pete Molly's Revenge http://www.mollysrevenge.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode -- Pete Molly's Revenge http://www.mollysrevenge.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Shell question
Pete- Sunday, January 8, 2012, 6:54:44 PM, you wrote: Those commands all work fine when typed into the program by me but nothing is written to the output file if I redirect stdin to a file that contains them. Ah. In that case, are you putting quotes around the shell command? Works here for me. put shell(myprog /Users/Pete/myfile.txt) into myResult -- -Mark Wieder mwie...@ahsoftware.net ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Shell question
The command is in a variable, eg put shell(myCommand) into myResult. I'm thinking it's something other than that though since even if I type the command directly into Terminal with the stdin redirection, no output is produced. sqlite3 has a .echo command which prints all the commands to stdin. If I put that into the stdin file, what gets displayed is portions of each command with no line breaks between them. It sure feels like some sort of carriage return problem! Pete On Sun, Jan 8, 2012 at 7:31 PM, Mark Wieder mwie...@ahsoftware.net wrote: Pete- Sunday, January 8, 2012, 6:54:44 PM, you wrote: Those commands all work fine when typed into the program by me but nothing is written to the output file if I redirect stdin to a file that contains them. Ah. In that case, are you putting quotes around the shell command? Works here for me. put shell(myprog /Users/Pete/myfile.txt) into myResult -- -Mark Wieder mwie...@ahsoftware.net ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode -- Pete Molly's Revenge http://www.mollysrevenge.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode