Bill Orcutt’s ‘shell’ object has gotten a bit long in the tooth and it was time for a major cleanup and, er, a complete rewrite, actually. An "early beta" is attached to this post, so give ‘er a spin and let me know how it goes.
- complete rewrite :-)
- initial implementation of interactive shell functionality:
- ‘penter’: if an interactive command is running, send the text + a carriage return
- ‘pwrite’: if an interactive command is running, send the text (no CR added)
but it’s still pretty rough ("top -s 1 -l 3600 -stats pid\,cpu\,time\,command" works, but can’t be controlled interactively, for instance. I could successfully SSH to another computer, though).
- infrastructure for a Windows CMD version added (but no, there’s not a Windows version yet and may not be for some time).
- new @stderr to optionally merge stderr with stdout
- not really well-tested yet
- This topic was modified 1 year by Jeremy. Reason: updated attachment
lekker! Thanks, Jeremy!
Thanks, thsi is a very useful object. One question though : does that update mean that now you can open an aplication which has no graphical interface ? or a command line application ?
You’ll need to provide an example. I’m not quite sure what you want to do.
Well anyway it seems to work, previously i could’nt make it work, but error was probably on my side, related more to bad filepath formatting (need \\ inside " " for each blank space ; \ is not enough) than this update…
…and what i tried to do is : launching an application which doesn’t have a graphical interface, through [shell]. It should be the same than an application with a graphical interface. That’s why my question could be confusing…
…Regarding the commandline applications, it is another question ; which answer is "yes, you can" using the new penter/pwrite message.
This is awesome ! thanks ! sorry for the confusing/confused questions :)
An application without a graphical interface is the same as a command line application, as far as I’m concerned. Anyway, yes, it all seems to be working for me. I’ve made a few improvements and updated a new version of the object to the original post: shell.mxo_1.zip
it’s an application that opens in a separate process than commandline, which you can’t interact with in console, but has no gui ; you just see its icon in the dock when it’s running. Then maybe it does have a gui, but an empty gui ; and maybe it’s an unwise programming practice !…
Ah ok, you mean a faceless background application, I guess. The point of the ‘shell’ object is to provide access to the OS shell — so you can launch or kill such an application, you can run an Applescript or similar which targets such an application, but if it doesn’t provide a command line interface, there’s not much you can do with it otherwise.
Faceless background application, that’s it ;) just launching it at a patcher’s loading is useful in my case.
Nice work. In the past I’ve handled shell stuff successfully from pyext, will have to give this a look.
thanks jeremy, you are a legend. this is big news.
especially excited by:
"infrastructure for a Windows CMD version added"
…with that added, there will be world peace.
Can someone help me out with my message formatting? Neither of these 2 options work for making ImageMagick produce an animated GIF. The bottom one works in Terminal.
I tried removing the space from the paths to no avail.
----------begin_max5_patcher---------- 1224.3ocyX0rjiZCD9r8SgJNrm7LFAXrcNjpRkC4XNjJmVmZJAHaqcAgij7L iyV66dZIAXv.1lYYmZtL3oa0p+6Sc2Rea5Dmn7WoRGzuf9LZxjuMcxDCIMgI E++DmLxqwoDoYYNYTojri5LyxSQeUYnGmyelJTnGRnojSHeWzCvWpPh9yCJV F6+nnMNy+aIPYdhRL+uNwimi8cWiCP+NiS+JKYNnn4R5+5t08wnrCabFfD3A Kg2PjPQkJuG2w1twozySA1w4G4F22qf31btRB9plF16Q2Bx7iYLdJUIqu1CB pjxUDEKm+jfFqroAerKHGBub4iKlgL+F9C5eJjJ+nB1H0oCT6xcbpXAZwx0n FboZHp38L9tNTwJr9yx.yGebMsvRLI07nu7f2BmZNGmjYTryuIXjTGMiuOcp 9OydG.PaFJDZiNAuYnvngJk2Pk5LbZyHBnFCng2pEFnQfqF8EtZ0UgFAiKzf SeA11VHiCBFWgRx4TmNhJq6Nnf6zycuxghEgZe0aou9yh.6Ijtc7tOR7GTN8 YxX53HohvSHhjGnBQtX.tu6Pc+.7Jq6qAYnBTPOte30b+BVw4ofAa1ZrsFle n6xUA5eEtxyeg+LTcXkwjnhhfTQTBz.KkBkEjPMxZY0INjCGpQdRMQzg1uXU c3rJRLtkDthjf9LqTduJpDADXTPT4nv5UutJzwxDRmSKEsLpE5Ybt.WavyyD 777CN6XPpeWZd7WoI0R.vY0CTNiWuEPC1Izsjiopm593eS9aIwzdE9hCkkKY mfAmmzFQCI0jKUGj2rffE0cFyJ3jCcHLfUUGkQDgNtFkRqGXcT44oMYUkJgi FDNKinnPYdqTtUaJKyb5ughnbBrG6kwh7zzFakkyycvIAx1wzWXIp8l8pdnD VN6PYJvoJFkv1AkoaRSQ1IaRow.T0gg0Oy2f9U6G1r.PpDsk.PGlFwkKNg79 0OgquxNqDzaGhazkn+NE82svL.gEmTLTQXM3xE0MZY5cU5bRY4yhybuwvZiR pc0OQpR.G8SvGn15aHlh6Mn4dOAMrscy50WVnsUS1OFAMUt7TVTd5OXjZ7Qe XWCtaA9VAR+aEHqwtc2qUqcwqCMyhW7KS2q2mfubOMc7i7yPNQD9tqkA7tqL f8iu6sx.AuiP437rLn0Z2gyhopPlopPwDNJhh.IhfQvSPuvT6KJOfhNg1B8R xeAbbDQulLPV6R13nKGWM.e6g38uqL1Vwtnl8jFwZMKsCjXq33YmUo+Dzh2P B57rAZeumVgFSSyu6LmL+nHtDWVfTPMsRnMshwqlT5yUEGuXc6YIIMGLw1KW pmLvNC1cgxFpE6emVbvGFKFemVr+HYwEEKKGi1QRdll7DnA.s9DQoDrniJK. p9M.9QG081iROf4+5zHthx6SovUBhHoE24oR1NFyb54f3XdYZa0selWmt3gD JtNcn20tO4xQ95z.NRAYyq4Gs5F1nS3.dujPaE1h2Kn0MlZL9avH91.0GIXH IvaOFP2i.bsbbfo++J70xwdt2YR1HbydI1vzk02JBVspqoevxyEr5qwgaiE0 phV6pYsRa2s8D7AydbuC6Y46q4fug4r3cybv+TyVVv8EOdk1Tt3Qqt3AqZ+X U88PUfd99z+2prJ9. -----------end_max5_patcher-----------
hmmmm, two possibilities…
1/either in the first case you need \ before each blank space
2/or you need to format the filepaths using conformpath. I can’t really do that here since i don’t have imagemagick
eitherway, sending something in hyphens (" ") should not work, you need the \ before each hyphen.
----------begin_max5_patcher---------- 1210.3ocyXszjhaCD9L7qPkOrmX.+BiIGRUoxgbLGRkSKaMkrs.zt1xNRhYF xV6+8zRx1iM1FvCDp8xHltUa08W+T56SmXEk+FQXg9EzmQSl78oSlnIoHLo7 +mXkgeKNEKzayJiHD3cDqYFdRxaRM83b1KDtD8TBIEeD4YidBVIbA5OKjzL5 +RParV72BfxhDIewecjEuvwydsiO52oLx2nIKfCZgf7O1asmGkUrwZDR3LZI bGiDRhP5NeGc6FqJKOE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dFNAHr+YrTxoQGjl.nl2.3VG08xiROh4+5UINyg OzgBWIHBmVdmmZY6YLyouCh2yKSaptM9qSW97SlqSG3dmtN8p670og3HI3MG 1NbCMWTKXc0MbZeOmqwN54oRb7G7AQZzf693GaNRv3cfA5VKgNeDGnaOuQj8 U7h.WpweItnUk18RLvzo02JAqt8NZUXanhZ1s1TmJZcql0wscs5i9nbtf9r7 wpNWBdV83Tme17VK++TeLA2m73UJU4jGs5jGrp6iUMzCUAmyOl9e.hlA0KC -----------end_max5_patcher-----------
(it seems to be something else entirely)
hey tanx, I ultimately went the pyext way since I need windows support as well
I had tried the \’s though
perhaps this helps:
----------begin_max5_patcher---------- 1432.3oc0Y0zaihCF9bxuBKjl4TZC1PHvdXkFsG1i6gU6ooipLfShmALYwNs M6n4+95O.Bj.DRSCSmVoPh+7wO98iGi+9zIVgYuP3VfeC7YvjIee5jI5hTEL o32SrRwuDkf45lYEtSHxXVyLUw1klsSjPD5JgEkZJRreKwLxVgX1ZKvWJpdK VDsgxV+XNIRXZgiu881y.Nd5GnpOq5CMVO6Yge8NnesYmxplbUY+X5T0GyF3 hgQdVNhkCmf7hFNVBPn4+1WltEktJiI3z+SuHgJH22peVGOGBqXdrH39Ey.P +NXEOqZvhgS0yt0mxo3jaMesMmrkvhAQYrmH4BvcwjD7dfiM3N4SRNG7WaEz TEU0qcyPIzdIMTAaUZDgTO5j0Pi.qkR3b7ZxIz1CVy+GtjclGKxm+26YQygN 1APWvePYjuQimKGk4BBWfteMc0CVkCPhr5nrcL8nft8LJDZbKcMTJDA0L6xN nT3ERonwlR4j+0dE59vzsG3zaH8E.qydHmEZRzqc1K3WBxCNZjm2xKf7b+kf 7rGMxqHwwvHOzHPdcj+fuMmxDq.OX9y5C7xu8pKZ7Rz3Zd.CB5MQyxkWH+5d 8FmCXwidslVPswDBYDkD3z2hGs3mni44EknLetPu2BitKLf4k1Kzk1qChEd3 5kKbklFvENJSC+.sZAGXGlFt+7B6ni5.hyXc3vX2BqDTQJ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3DLtvw4LvABGO73O.imirvto3Qc+ HmGPin4LbH3QiZmQAPACFOnQAOtCFOvQAOnAimww.RcoWumRWfbemgG6Afmk iKbNW5qEiW3ma5tkQKzQ20gBJGcGGGc+Fmd2FccuFx44GS+e.jb1KsA -----------end_max5_patcher-----------
If I want AppleScript Editor to run a script, what message do I have to send to the shell object?
Hahahah ! it toggled the system shell!!
I’m having a heck of a time being able to ssh to another computer.
My message into [shell] is as follows:
It works like a champ in Terminal, but I can’t get it to respond in Max.
I’m an sound/interface guy and I don’t have a ton of experience in terminal, but I’ve searched all over the forums and other sites for answers, and I just can’t seem to find out what I’m doing wrong.
Recently I was working with shell and realised that, where commands in Terminal are executed with default arguments, in this case you need to provide them. I understand that’s why, as an example, you can type
top in Terminal, but in max that doesn’t work (and
top -s 1 -l 3600 -stats pid\,cpu\,time\,command does). The ssh command I don’t (didn’t) know, but I see that typing ssh [Enter] in the Terminal gives all possible arguments. Does this make any sense?
I’m investigating making an editor for Composers Desktop Project using shell but I can’t seem to change directory with cd. I’m not a pro with terminal but I expect that when i send cd ~/sounds i should then be able to do ls to see whats in the folder – am I misunderstanding?
- This reply was modified 9 months by leafcutter.
Yes that what I thought I was seeing with the shell object.
In CDP in terminal you would negotiate to your sounds folder, then run something like:
filter fixed 1-2 soundin.wav soundout.wav boost/cut freq
filter fixed 1-2 ~/sounds/soundin.wav ~/sounds/soundout.wav boost/cut freq
But it didn’t work, does anyone have a clue as to how I might be able to get it to work?
I would be great to have an editor for the amazing treatments available in CDP.
Ive managed to find a way of doing it. Write the command as a text file, then set its permissions and then run it. Seems to work.
In my user home folder .bash_profile file I’ve added an alias to an applescript like this:
alias spotify="osascript /Users/name/Documents/SpotifyControl.scpt"
In the terminal I now can use the command spotify, but when I try to pass this command to the shell.mxo object I get this as output:
stdout: sh: spotify: command not found
How do I make this shell object aware of the paths and aliases in .bash_profile?
I’ve got it working
Just pass the scriptname as command like this:
osascript /Users/name/Documents/SpotifyControl.scpt next
@Jeremy: will there be a 64-bit version? I am more and more forced to go 64-bit (my patches grow too big…;-)
have you tried it? i’m pretty sure i used it in a 64bit environment. both versions should be combined in one file for mac externals. O.
thanks for the update on shell, jeremy !!
i was looking into shell now again, since i want to workaround the sleeping [suspend] external.
but i am not too familiar with all the unix-commands, can anybody think of a way
"getting the current frontmost application" out of shell?
You could do this by calling a applescript through osascript
In applescript you can make any application frontmost or query "System Events" to get the current front most
It is 64-bit, I had a version clash with an old shell object from Jamoma…
I’ve been using this heavily lately and am getting used to the quirks. Cant figure out stderr argument though. How does it work?
A simplish(?) question. Is there a way to thread the shell object? I’m using it as an interface to text-to-speech on osx so sending commands like this:
‘say "hello world" ‘
That works fine but I’d like to be able to say things in an overlapping fashion. In the terminal I can open several terminal windows and execute the command in one after another causing the speech to overlap. I don’t understand what’s going on in the background with this object so it’s hard to know where to go. I tried using ‘nohup COMMAND &’ to return to the prompt which works in a terminal window but not with this object. Any ideas?
thanks in advance for any pointers
You could put the shell in a poly~ and treat it like any other polyphonic synth.
I am using the shell extension to allow me to run python code I have written to remotely control gear. Each time I open max and the patcher ‘shell’ comes in as jbogus. If I double click the shell.mxo and retype shell in the object it gets updated. I have this external stored in:
My default Folder for device projects is set to:
"main:/Users/mennis/Documents/Max 7/Max for Live Devices"
while my folder for Projects is set to:
I would like to launch a command-line application i installed recently, node.js, but when i send the message (node 2>&1) to [shell], i get a :
sh: node: command not found
However if i try the same thing from the terminal, it works normally. Is there somewhere i should install that command-line application again ?
@Michealian ennis : in the "package" folder, there is a precise folder structure to follow, otherwise it’s bound to be bogus at some point
In this case it should be something like
i just solved my problem… Apparently, Max’s shell doesn’t have access to user-installed command line tools, so by entering the full path of the command-line tool instead of just the command line ; [shell] can find it and the problem is solved. In my case it was there :
it’s probably a common place for installed command line tools ?..
There should be a way to simplify this ; but i don’t know it
Jeremy, thank you a lot for this. For me it brings max to a new level!
Is there anyone who would share a example for a ssh connection. When I send ‘ssh user@Ip’ the terminal waits for a password. When I send the password in a second message -> there is no reaction anymore from the terminal. If anyone has a solution for this, please share!