Forums > Beta

shell 2013

August 12, 2013 | 7:26 am

Hi y’all,

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

Known issues:
– not really well-tested yet

  • This topic was modified 2 years by  Jeremy. Reason: updated attachment
August 12, 2013 | 2:43 pm

lekker! Thanks, Jeremy!

August 13, 2013 | 3:03 am

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 ?

August 13, 2013 | 3:06 am

You’ll need to provide an example. I’m not quite sure what you want to do.

August 13, 2013 | 6:10 am

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…

August 13, 2013 | 9:09 am

…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 :)

August 13, 2013 | 9:22 am

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:

August 14, 2013 | 3:09 am

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 !…

August 14, 2013 | 3:31 am

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.

August 14, 2013 | 6:45 am

Faceless background application, that’s it ;) just launching it at a patcher’s loading is useful in my case.

August 14, 2013 | 9:06 am

Nice work. In the past I’ve handled shell stuff successfully from pyext, will have to give this a look.

August 23, 2013 | 4:11 am

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.

September 22, 2013 | 11:41 am

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.


— Pasted Max Patch, click to expand. —


September 22, 2013 | 6:28 pm

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.


— Pasted Max Patch, click to expand. —


September 22, 2013 | 6:43 pm

(it seems to be something else entirely)

September 23, 2013 | 12:08 pm

hey tanx, I ultimately went the pyext way since I need windows support as well

I had tried the \’s though

September 23, 2013 | 12:09 pm

perhaps this helps:

— Pasted Max Patch, click to expand. —


November 30, 2013 | 2:21 am

Thanks! Great!

If I want AppleScript Editor to run a script, what message do I have to send to the shell object?


December 16, 2013 | 1:27 am

Hahahah ! it toggled the system shell!!

December 16, 2013 | 1:33 am

@ubu, you want "osascript": more info

February 27, 2014 | 11:43 am

Hi All-
I’m having a heck of a time being able to ssh to another computer.
My message into [shell] is as follows:

ssh (username)@(localIP)

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.


February 27, 2014 | 11:45 pm

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?

May 21, 2014 | 4:06 pm

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?

May 21, 2014 | 11:52 pm

@leafcutter: it’s true in a real shell, but cd doesn’t seem to work in the shell object (nor does pushd). pwd returns the current working directory, and always returns /
ls -l ~/sounds does work.

May 22, 2014 | 3:47 am

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

I tried:

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.

May 22, 2014 | 5:41 am

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.

May 31, 2014 | 1:19 pm

Hi All,

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?

Frans-Jan Wind

May 31, 2014 | 1:25 pm

I’ve got it working
Just pass the scriptname as command like this:
osascript /Users/name/Documents/SpotifyControl.scpt next

June 5, 2014 | 7:15 am

@Jeremy: will there be a 64-bit version? I am more and more forced to go 64-bit (my patches grow too big…;-)

June 5, 2014 | 3:56 pm

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.

June 10, 2014 | 5:20 am

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?
\thx klaus

June 10, 2014 | 7:19 am

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

June 12, 2014 | 10:04 am

It is 64-bit, I had a version clash with an old shell object from Jamoma…

August 29, 2014 | 9:03 am

I’ve been using this heavily lately and am getting used to the quirks. Cant figure out stderr argument though. How does it work?

September 7, 2014 | 5:04 pm

Hi folks,

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

September 7, 2014 | 11:59 pm

Hi Tom,

You could put the shell in a poly~ and treat it like any other polyphonic synth.

January 11, 2015 | 3:33 pm

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:

/Users/mennis/Documents/Max\ 7/Packages/externs/shell.mxo

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:
"main:/Users/mennis/Documents/Max 7/Projects"

February 4, 2015 | 5:46 pm

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
/Users/mennis/Documents/Max\ 7/Packages/externs/externals/shell.mxo
/Users/mennis/Documents/Max\ 7/Packages/shell/externals/shell.mxo

February 4, 2015 | 8:17 pm

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

February 12, 2015 | 7:27 am

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!

March 8, 2015 | 3:56 pm

I’m also trying to ssh, I’m prompted for a password, but entering it receives no response at all. Anyone managed to do this?

March 9, 2015 | 11:25 am

in the terminal you need input each letter of the password sequentially ; did you try sending each password character one after the other to shell ? or maybe sending the pass with penter ?

March 9, 2015 | 3:09 pm

I tried entering them sequentially with separate message boxes for each character but that didn’t work. Not sure if I’m using penter right, tried a message box with [password penter] and [password -penter] but didn’t work either.

April 20, 2015 | 12:59 am

Needed enter first:
ssh servername
penter password

Then penter for commands too:
penter cd
penter ls
etc etc

April 29, 2015 | 7:23 am

Well, this seems to be the place to ask for a little help using shell to report MaxMSP memory usage in real time from within Max.

I’ve managed to get "top" spitting out data, but it is not reporting memory usage, only CPU usage.

Also, can’t seem to figure out how to parse it so I just get MaxMSP related information.

I’m very new to this. If anyone is willing to help, or point me down a path to edgicate myself, I would appreciate it very much.

June 5, 2015 | 6:41 am

Hello guys. First of all, thanks to Jeremy for this wonderful object. I’ve created a patch using [shell] capable of reporting Max’s Memory (@T_BRUCE what you needed) and overall CPU usage (useful for Jitter users). It uses two instances of [shell] to get Max’s PID and then get the desired info. Hope this is helpful!

— Pasted Max Patch, click to expand. —
June 29, 2015 | 6:30 am

Hi, when I try to perform a cp command to copy a file to a protected directory like Library/Frameworks, I have to precede the cp cpmmand with a sudo -v command, but where I have to put the password? I have to append penter? this makes reapparing the password question…confused.
Example: sudo -v <password> penter…no success, or sudo -v <password> pwrite ….no success. What string should I use?

June 29, 2015 | 4:24 pm

Maybe I’ve found: this seems to be working: echo password’ | sudo -S penter

September 4, 2015 | 6:53 am

Did anybody succeed in opening a python file?

python ~/Desktop/
/usr/bin/python ~/Desktop/
usr/bin/python ~/Desktop/

all didn’t work, whereas in the Terminal it did.

September 4, 2015 | 3:52 pm

maybe try prepending the word open:
open ~/Desktop/
open python ~/Desktop/

September 4, 2015 | 4:16 pm

Set first the application witch you need to open the file (IDLE or Phyton launcher), then run the shell patch.

  1. Schermata-2015-09-05-alle-01.13.50


  2. Schermata-2015-09-05-alle-01.13.27


September 9, 2015 | 1:38 am

Okay, formatting is key so I ended up using [textedit] instead of [message] which made it al work, except for user installed programs. Thanks though!

September 10, 2015 | 3:10 pm


I’m trying to create what I thought would be a simple patch to print a blank document from my printer with Max. No luck so far. This is what I have. Any of you able to tell what I’m doing wrong?

I’m using Max7 on a macbook pro os 10.10



— Pasted Max Patch, click to expand. —
September 10, 2015 | 3:19 pm

Works fine with me. Although I did remove the 1 before pr.
And just to be sure. Pr prints the file to the standard output of the shell, not the printer. LPR does that but I’m not sure how you need configure that.

Open up terminal and type: man lpr
to check how that works. I never tried it.

— Pasted Max Patch, click to expand. —
September 10, 2015 | 3:21 pm

Nevermind, my printer was paused :-/

Here is the working patch for anyone else who wishes to print from Max

— Pasted Max Patch, click to expand. —
October 21, 2015 | 2:14 pm

pkill seems to crash Max, all else with top seems to be working well though!

November 20, 2015 | 4:49 pm

Great stuff!

I was wondering how one could launch an application, that is valid for different users?
open ~/Documents/Max 7/Library/foo/bar
doesn’t work for me, while
open /Volumes/hdd/foo/bar

February 7, 2016 | 11:09 am

I’m trying to use ffmpeg command with [shell] to convert video files, but with no success (it works perfectly within terminal).
Is there another way to do it within max? Thanx

February 7, 2016 | 12:06 pm

I’m trying to use ffmpeg command with [shell] to convert video files, but with no success (it works perfectly within terminal).
Is there another way to do it within max? Thanx

— Pasted Max Patch, click to expand. —
February 7, 2016 | 2:44 pm

Thanx to vichug for his post from FEBRUARY 4, 2015 | 8:17 PM cause it works :)

— Pasted Max Patch, click to expand. —
February 7, 2016 | 4:07 pm

I posted this question in a separated thread, but maybe it’s better here:

I started thinking about using the system tag in 10.10 and above (maybe 10.9 also)
I found this command line which does a great job in the terminal:
Now I would like to find a way to use it inside max.
Just sending tag command to shell does not work….
Any thoughts ?

February 8, 2016 | 5:56 am

Yoann try sending /usr/local/bin/tag to shell.

Viewing 62 posts - 1 through 62 (of 62 total)

Forums > Beta