Re: What's the difference between LC 'shell' and OSX terminal?
shell is a function, you have to actually do something with what is returned. notice if you do the following from the message box: shell() with nothing, you get handler not found If you do this instead put shell() you get bad parameter because you didn't give the function anything to work with. So, if you do put shell(/opt/local/bin/convert --help) you will most likely get the help text for convert. If you are doing it correctly, (IE as in the above examnple) and are still getting a handler error, there is something else going on. On Sat, Oct 29, 2011 at 8:40 AM, Graham Samuel livf...@mac.com wrote: Thanks to all who replied. Just a brief reminder that I found I could invoke ImageMagick from Terminal on my Mac, but not via 'shell' within an LC program on the same machine. I really hoped that Andre's insight was right and that it was a path issue - really because I understand what one of those is! Anyway on your advice, Andre, I did: which convert in Terminal, and got: /opt/local/bin/convert I don't exactly know what 'opt' is, but I can open /opt/local/bin/ in the Mac Finder, so it exists OK, and it contains a file 'convert' as expected. Anyway I tried doing this in the LS message box: shell(/opt/local/bin/convert) and got: Message execution error: Error description: Handler: can't find handler Hint: shell(/opt/local/bin/convert) I then set the defaultFolder to /opt/local/bin/, and the Message Box couldn't even recognise 'shell'! So very sadly, that didn't work. Neither did it work when I put the whole shell argument in quotes, nor could shell find other commands such as 'which' or 'cd' with or without the path data. Andre's solution seems so logical… any more suggestions? Incidentally, on my machine shellCommand is set to: /bin/sh which AFAIK is what it's supposed to be. TIA Graham Thanks also to Mike Bonner for his advice on command lines (some of which I understood, although I'd never heard of a profile in the sense Mike uses, so I am a bit at sea there). Also, although currently I'm just experimenting, I'm always looking for solutions which would work in a complete cross-platform app built for people who just want to use the computer as a tool. In that context any 'tinkering' with the environment would have to be done via LS, and within that via shell, so as to protect my user - I'm not sure if this is possible or not, but I'll keep trying to understand it. In my encounters with ImageMagick the really interesting thing I've learned so far is the philosophical difference between 'nix users and Mac/PC users - it's geeks versus consumers really. I was once a geek myself, in some pretty tough technical environments, but the reason I use LS is because I stopped being one. ___ 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: What's the difference between LC 'shell' and OSX terminal?
Wasn't real clear there.. Yes shell is a function, but livecode uses subtle clues to interpret what is what. So a function on a line by itself with no way to handle the output is instead seen as a handler because the engine is making its best guess. And since there is no handler named shell() you get the error message you see. As soon as you include some way of using what the function returns the engine is back in happy land. As mentioned by everyone though, spaces and strange chars in paths and commands can cause funky results including a handler not found as above all depending on how the engine guesses. On Sat, Oct 29, 2011 at 8:48 AM, Mike Bonner bonnm...@gmail.com wrote: shell is a function, you have to actually do something with what is returned. notice if you do the following from the message box: shell() with nothing, you get handler not found If you do this instead put shell() you get bad parameter because you didn't give the function anything to work with. So, if you do put shell(/opt/local/bin/convert --help) you will most likely get the help text for convert. If you are doing it correctly, (IE as in the above examnple) and are still getting a handler error, there is something else going on. On Sat, Oct 29, 2011 at 8:40 AM, Graham Samuel livf...@mac.com wrote: Thanks to all who replied. Just a brief reminder that I found I could invoke ImageMagick from Terminal on my Mac, but not via 'shell' within an LC program on the same machine. I really hoped that Andre's insight was right and that it was a path issue - really because I understand what one of those is! Anyway on your advice, Andre, I did: which convert in Terminal, and got: /opt/local/bin/convert I don't exactly know what 'opt' is, but I can open /opt/local/bin/ in the Mac Finder, so it exists OK, and it contains a file 'convert' as expected. Anyway I tried doing this in the LS message box: shell(/opt/local/bin/convert) and got: Message execution error: Error description: Handler: can't find handler Hint: shell(/opt/local/bin/convert) I then set the defaultFolder to /opt/local/bin/, and the Message Box couldn't even recognise 'shell'! So very sadly, that didn't work. Neither did it work when I put the whole shell argument in quotes, nor could shell find other commands such as 'which' or 'cd' with or without the path data. Andre's solution seems so logical… any more suggestions? Incidentally, on my machine shellCommand is set to: /bin/sh which AFAIK is what it's supposed to be. TIA Graham Thanks also to Mike Bonner for his advice on command lines (some of which I understood, although I'd never heard of a profile in the sense Mike uses, so I am a bit at sea there). Also, although currently I'm just experimenting, I'm always looking for solutions which would work in a complete cross-platform app built for people who just want to use the computer as a tool. In that context any 'tinkering' with the environment would have to be done via LS, and within that via shell, so as to protect my user - I'm not sure if this is possible or not, but I'll keep trying to understand it. In my encounters with ImageMagick the really interesting thing I've learned so far is the philosophical difference between 'nix users and Mac/PC users - it's geeks versus consumers really. I was once a geek myself, in some pretty tough technical environments, but the reason I use LS is because I stopped being one. ___ 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: What's the difference between LC 'shell' and OSX terminal?
On Sat, Oct 29, 2011 at 10:40 AM, Graham Samuel wrote: Thanks to all who replied. in Terminal, and got: /opt/local/bin/convert I don't exactly know what 'opt' is, but I can open /opt/local/bin/ in the Mac Finder, so it exists OK, and it contains a file 'convert' as expected. Anyway I tried doing this in the LS message box: shell(/opt/local/bin/convert) and got: Message execution error: Error description: Handler: can't find handler Hint: shell(/opt/local/bin/convert) You are so close. :-) and got: is the clue. You could not have got unless you first GET. Also, quotes around the path should help. Try this in the message box: get shell(/opt/local/bin/convert) ˜Roger ___ 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: What's the difference between LC 'shell' and OSX terminal?
On 10/29/2011 09:40 AM, Graham Samuel wrote: shell(/opt/local/bin/convert) Mike's response contains all the correct information, but it can be distilled to this: change what you what you type into the message box to: put shell(/opt/local/bin/convert) This should display in the message box whatever the terminal displays after you type convert in Terminal and press enter. The put is what will cause the output to be displayed. On my machine, issuing the convert command without any args returns the help. This is not uncommon behavior for cli programs. Also I note that while it is very common to require two hyphens before whole word args, 'convert' doesn't seem to use any single letter args and only responds to single hyphen (as compiled on my machine) args. This is from the help itself: -help print program options Try: put shell(/opt/local/bin/convert -help) works for me here, but if not for you, then: put shell(/opt/local/bin/convert --help) In an application you might prefer to use get in place of put before your shell(). Best, Warren ___ 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: What's the difference between LC 'shell' and OSX terminal?
Ah k yep. the double dash help is a pretty common unix'y thing, haven't used IM to convert and no mac so couldn't test. Thx for clarifying! On Sat, Oct 29, 2011 at 9:34 AM, Warren Samples war...@warrensweb.uswrote: On 10/29/2011 09:40 AM, Graham Samuel wrote: shell(/opt/local/bin/convert) Mike's response contains all the correct information, but it can be distilled to this: change what you what you type into the message box to: put shell(/opt/local/bin/convert**) This should display in the message box whatever the terminal displays after you type convert in Terminal and press enter. The put is what will cause the output to be displayed. On my machine, issuing the convert command without any args returns the help. This is not uncommon behavior for cli programs. Also I note that while it is very common to require two hyphens before whole word args, 'convert' doesn't seem to use any single letter args and only responds to single hyphen (as compiled on my machine) args. This is from the help itself: -help print program options Try: put shell(/opt/local/bin/convert -help) works for me here, but if not for you, then: put shell(/opt/local/bin/convert --help) In an application you might prefer to use get in place of put before your shell(). Best, Warren __**_ 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-livecodehttp://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: What's the difference between LC 'shell' and OSX terminal?
on a side note regarding shell - I just ran this from the message box: put shell(man zip) and got this text: (clip) ZIP(1L) ZIP(1L) NNAAMMEE zip - package and compress (archive) files SSYYNNOOPPSSIISS zziipp [-aaAABBccddDDeeEEffFFgghhjjkkllLLmmooqqrrRRSSTTuuvvVVwwXXyyzz!!@@$$] [--longoption ...] [-bb path] [-nn suffixes] [-tt date] [- date] [_z_i_p_f_i_l_e [_f_i_l_e ...]] [--xxii list] (/clip) what is the text encoding in the man pages? In terminal the doubled characters show up as boldface. Stephen Barncard San Francisco Ca. USA more about sqb http://www.google.com/profiles/sbarncar ___ 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: What's the difference between LC 'shell' and OSX terminal?
On 10/29/2011 12:59 PM, stephen barncard wrote: on a side note regarding shell - I just ran this from the message box: put shell(man zip) and got this text: Not an answer to your question, but that doesn't happen here running Linux. Here is something from discussion of Phil Davis' Shell Command Help plugin: http://lists.runrev.com/pipermail/use-livecode/2011-January/151041.html and the next few messages. Warren ___ 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: What's the difference between LC 'shell' and OSX terminal?
You can get the Shell Command Help plugin from Rev Online. I use it almost every day. :-) Phil On 10/29/11 11:53 AM, Warren Samples wrote: On 10/29/2011 12:59 PM, stephen barncard wrote: on a side note regarding shell - I just ran this from the message box: put shell(man zip) and got this text: Not an answer to your question, but that doesn't happen here running Linux. Here is something from discussion of Phil Davis' Shell Command Help plugin: http://lists.runrev.com/pipermail/use-livecode/2011-January/151041.html and the next few messages. Warren ___ 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 -- Phil Davis PDS Labs Professional Software Development http://pdslabs.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: What's the difference between LC 'shell' and OSX terminal?
thanks guys. Phil's snippet in the archives was educational: There are always variations of unix commands that will do what one wants. sqb On 29 October 2011 12:11, Phil Davis rev...@pdslabs.net wrote: You can get the Shell Command Help plugin from Rev Online. I use it almost every day. :-) Phil On 10/29/11 11:53 AM, Warren Samples wrote: On 10/29/2011 12:59 PM, stephen barncard wrote: on a side note regarding shell - I just ran this from the message box: put shell(man zip) and got this text: Not an answer to your question, but that doesn't happen here running Linux. Here is something from discussion of Phil Davis' Shell Command Help plugin: http://lists.runrev.com/**pipermail/use-livecode/2011-** January/151041.htmlhttp://lists.runrev.com/pipermail/use-livecode/2011-January/151041.html and the next few messages. Warren __**_ 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-livecodehttp://lists.runrev.com/mailman/listinfo/use-livecode -- Phil Davis PDS Labs Professional Software Development http://pdslabs.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-livecodehttp://lists.runrev.com/mailman/listinfo/use-livecode -- Stephen Barncard San Francisco Ca. USA more about sqb http://www.google.com/profiles/sbarncar ___ 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: What's the difference between LC 'shell' and OSX terminal?
Thanks to Roger Eller and Mike Bonner - shell is a function! Of course it is, it says so in the LS documentation, even though the examples don't show it embedded in a function-using script. I got it wrong because I didn't read the docs closely enough - I imagined that it was a handler that acted exactly like a command line in Terminal - but of course it also returns a result! Anyway that particular problem is solved along with the earlier one about paths (thanks Andre Garzia) and I can now run IM from shell. Graham On Sat, 29 Oct 2011 11:20:49 -0400, Roger Eller roger.e.el...@sealedair.com wrote: On Sat, Oct 29, 2011 at 10:40 AM, Graham Samuel wrote: Thanks to all who replied. in Terminal, and got: /opt/local/bin/convert I don't exactly know what 'opt' is, but I can open /opt/local/bin/ in the Mac Finder, so it exists OK, and it contains a file 'convert' as expected. Anyway I tried doing this in the LS message box: shell(/opt/local/bin/convert) and got: Message execution error: Error description: Handler: can't find handler Hint: shell(/opt/local/bin/convert) You are so close. :-) and got: is the clue. You could not have got unless you first GET. Also, quotes around the path should help. Try this in the message box: get shell(/opt/local/bin/convert) ?Roger And Mike Bonner bonnm...@gmail.com wrote (in part): To: How to use LiveCode use-livecode@lists.runrev.com Wasn't real clear there.. Yes shell is a function, but livecode uses subtle clues to interpret what is what. So a function on a line by itself with no way to handle the output is instead seen as a handler because the engine is making its best guess. And since there is no handler named shell() you get the error message you see. As soon as you include some way of using what the function returns the engine is back in happy land. As mentioned by everyone though, spaces and strange chars in paths and commands can cause funky results including a handler not found as above all depending on how the engine guesses. ___ 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: What's the difference between LC 'shell' and OSX terminal?
On 10/28/2011 11:52 AM, Graham Samuel wrote: While trying to get just a bit comfortable with a command-line interface, I started Terminal on Mac OSX Lion and eventually got a command to work (after finding out how to cope with spaces in file and folder names). I put the same thing in an LC 'shell' command and got a runtime error (Handler: can't find handler). I guess this is because in the Terminal context, the shell recognised the program I was calling ('convert' - it's dear old ImageMagick) but within my prog and the LS IDE it didn't. What do I need to do to get 'my' shell to be able to invoke the same apps that the raw terminal interface can? My guess is that it's something to do with a context variable like LS's defaultFolder, but I just don't know how to get there. Can anyone explain? TIA Graham Graham, post the exact code you're trying to make work using Livecode's shell() function so it can be debugged. The shell function should have access to any command the terminal has access to. Best, Warren ___ 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: What's the difference between LC 'shell' and OSX terminal?
On 10/28/2011 11:52 AM, Graham Samuel wrote: While trying to get just a bit comfortable with a command-line interface, I started Terminal on Mac OSX Lion and eventually got a command to work (after finding out how to cope with spaces in file and folder names). I put the same thing in an LC 'shell' command and got a runtime error (Handler: can't find handler). I guess this is because in the Terminal context, the shell recognised the program I was calling ('convert' - it's dear old ImageMagick) but within my prog and the LS IDE it didn't. What do I need to do to get 'my' shell to be able to invoke the same apps that the raw terminal interface can? My guess is that it's something to do with a context variable like LS's defaultFolder, but I just don't know how to get there. Can anyone explain? TIA Graham Paste this in the message box: put shell(convert) and see what happens. You should get usage information from ImageMagick. To add a path to the input and output files inside the quoted shell command try surrounding the paths with single quotes. Warren ___ 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: What's the difference between LC 'shell' and OSX terminal?
Is this in Windows or Mac? Im Mac to get usage for a shell command you have to preface it with man. I think it's short for manual. This only works if whatever installed the command in the shell also installed a man page. Bob On Oct 28, 2011, at 7:06 AM, Warren Samples wrote: On 10/28/2011 11:52 AM, Graham Samuel wrote: While trying to get just a bit comfortable with a command-line interface, I started Terminal on Mac OSX Lion and eventually got a command to work (after finding out how to cope with spaces in file and folder names). I put the same thing in an LC 'shell' command and got a runtime error (Handler: can't find handler). I guess this is because in the Terminal context, the shell recognised the program I was calling ('convert' - it's dear old ImageMagick) but within my prog and the LS IDE it didn't. What do I need to do to get 'my' shell to be able to invoke the same apps that the raw terminal interface can? My guess is that it's something to do with a context variable like LS's defaultFolder, but I just don't know how to get there. Can anyone explain? TIA Graham Paste this in the message box: put shell(convert) and see what happens. You should get usage information from ImageMagick. To add a path to the input and output files inside the quoted shell command try surrounding the paths with single quotes. Warren ___ 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: What's the difference between LC 'shell' and OSX terminal?
On 10/28/2011 12:53 PM, Bob Sneidar wrote: Is this in Windows or Mac? Im Mac to get usage for a shell command you have to preface it with man. I think it's short for manual. This only works if whatever installed the command in the shell also installed a man page. Bob Technically you are correct, he'll get help but for our purpose here usage seemed like an acceptable description of what he'll see. Beat me with a stick. Warren ___ 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: What's the difference between LC 'shell' and OSX terminal?
Graham, This is probably a PATH issue. See when you launch your terminal, a bash script is executed. You can think of this script as the code in preOpenTerminal. Among other things, this script will set the PATH variable which holds a list of folders to look for commands in. So when you use the convert command, bash (which is the shell you are using in your terminal) will look inside those folders for a convert command. When you execute shell() on your LiveCode script, this bash initialization stuff is not run so the PATH variable will hold other things and there is a chance that the folder where imagemagick is installed is not there. Try this on your terminal: which convert This will return the path to the convert command, in my case is: /usr/local/bin/convert So change your convert command in the shell to /usr/local/bin/convert image.jpg blabla and see if you can get it to work. (I may of course be wrong and the problem may lie elsewhere) Andre On Fri, Oct 28, 2011 at 2:52 PM, Graham Samuel livf...@mac.com wrote: While trying to get just a bit comfortable with a command-line interface, I started Terminal on Mac OSX Lion and eventually got a command to work (after finding out how to cope with spaces in file and folder names). I put the same thing in an LC 'shell' command and got a runtime error (Handler: can't find handler). I guess this is because in the Terminal context, the shell recognised the program I was calling ('convert' - it's dear old ImageMagick) but within my prog and the LS IDE it didn't. What do I need to do to get 'my' shell to be able to invoke the same apps that the raw terminal interface can? My guess is that it's something to do with a context variable like LS's defaultFolder, but I just don't know how to get there. Can anyone explain? TIA Graham ___ 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 -- http://www.andregarzia.com -- All We Do Is Code. http://fon.nu -- minimalist url shortening service. ___ 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: What's the difference between LC 'shell' and OSX terminal?
On 10/28/2011 03:09 PM, Andre Garzia wrote: Try this on your terminal: which convert This will return the path to the convert command, in my case is: /usr/local/bin/convert So change your convert command in the shell to /usr/local/bin/convert image.jpg blabla and see if you can get it to work. (I may of course be wrong and the problem may lie elsewhere) Andre This would have been my suggestion if his shell() looked ok. It does point out a problem with using shell(), especially in OS X where things are very possibly not going to be installed in their standard *nix locations. A method to check for the location of an exectuable and if necessary, a way for the user to provide the path, should be provided. Warren ___ 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