shell 2013

    Aug 12 2013 | 2:26 pm
    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

    • Aug 12 2013 | 9:43 pm
      lekker! Thanks, Jeremy!
    • Aug 13 2013 | 10: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 ?
    • Aug 13 2013 | 10:06 am
      You'll need to provide an example. I'm not quite sure what you want to do.
    • Aug 13 2013 | 1:10 pm
      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...
    • Aug 13 2013 | 4:09 pm
      ...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 :)
    • Aug 13 2013 | 4:22 pm
      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:
    • Aug 14 2013 | 10: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 !...
    • Aug 14 2013 | 10: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.
    • Aug 14 2013 | 1:45 pm
      Faceless background application, that's it ;) just launching it at a patcher's loading is useful in my case.
    • Aug 14 2013 | 4:06 pm
      Nice work. In the past I've handled shell stuff successfully from pyext, will have to give this a look.
    • Aug 23 2013 | 11: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.
    • Sep 22 2013 | 6:41 pm
      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.
    • Sep 23 2013 | 1:28 am
      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.
    • Sep 23 2013 | 1:43 am
      (it seems to be something else entirely)
    • Sep 23 2013 | 7:08 pm
      hey tanx, I ultimately went the pyext way since I need windows support as well
      I had tried the \'s though
    • Sep 23 2013 | 7:09 pm
      perhaps this helps:
    • Nov 30 2013 | 10:21 am
      Thanks! Great!
      If I want AppleScript Editor to run a script, what message do I have to send to the shell object?
    • Dec 16 2013 | 9:27 am
      Hahahah ! it toggled the system shell!!
    • Dec 16 2013 | 9:33 am
      @ubu, you want "osascript": more info
    • Feb 27 2014 | 7:43 pm
      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.
    • Feb 28 2014 | 7:45 am
      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 | 11: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 22 2014 | 6:52 am
      @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 | 10: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 | 12:41 pm
      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 | 8: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 | 8:25 pm
      I've got it working
      Just pass the scriptname as command like this:
      osascript /Users/name/Documents/SpotifyControl.scpt next
    • Jun 05 2014 | 2:15 pm
      @Jeremy: will there be a 64-bit version? I am more and more forced to go 64-bit (my patches grow too big...;-)
    • Jun 05 2014 | 10: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.
    • Jun 10 2014 | 12:20 pm
      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
    • Jun 10 2014 | 2:19 pm
      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
    • Jun 12 2014 | 5:04 pm
      It is 64-bit, I had a version clash with an old shell object from Jamoma...
    • Aug 29 2014 | 4:03 pm
      I've been using this heavily lately and am getting used to the quirks. Cant figure out stderr argument though. How does it work?
    • Sep 08 2014 | 12:04 am
      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
    • Sep 08 2014 | 6:59 am
      Hi Tom,
      You could put the shell in a poly~ and treat it like any other polyphonic synth.
    • Jan 11 2015 | 11: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"
    • Feb 05 2015 | 1:46 am
      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
    • Feb 05 2015 | 4:17 am
      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
    • Feb 12 2015 | 3:27 pm
      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!
    • Mar 08 2015 | 10: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?
    • Mar 09 2015 | 6:25 pm
      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 ?
    • Mar 09 2015 | 10: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.
    • Apr 20 2015 | 7:59 am
      Needed enter first:
      ssh servername
      penter password
      Then penter for commands too:
      penter cd
      penter ls
      etc etc
    • Apr 29 2015 | 2:23 pm
      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.
    • Jun 05 2015 | 1:41 pm
      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!
    • Jun 29 2015 | 1:30 pm
      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 success, or sudo -v pwrite success. What string should I use?
    • Jun 29 2015 | 11:24 pm
      Maybe I've found: this seems to be working: echo password' | sudo -S penter
    • Sep 04 2015 | 1:53 pm
      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.
    • Sep 04 2015 | 10:52 pm
      maybe try prepending the word open:
      open ~/Desktop/
      open python ~/Desktop/
    • Sep 04 2015 | 11:16 pm
      Set first the application witch you need to open the file (IDLE or Phyton launcher), then run the shell patch.
    • Sep 09 2015 | 8: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!
    • Sep 10 2015 | 10: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
    • Sep 10 2015 | 10: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.
    • Sep 10 2015 | 10:21 pm
      Nevermind, my printer was paused :-/
      Here is the working patch for anyone else who wishes to print from Max
    • Oct 21 2015 | 9:14 pm
      pkill seems to crash Max, all else with top seems to be working well though!
    • Nov 21 2015 | 12:49 am
      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
    • Feb 07 2016 | 7:09 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
    • Feb 07 2016 | 8: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
    • Feb 07 2016 | 10:44 pm
      Thanx to vichug for his post from FEBRUARY 4, 2015 | 8:17 PM cause it works :)
    • Feb 08 2016 | 12:07 am
      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 ?
    • Feb 08 2016 | 1:56 pm
      Yoann try sending /usr/local/bin/tag to shell.
    • Feb 09 2016 | 6:39 pm
      _HasBeen_, it didn't work but it gave me the right direction, the correct path was /opt/local/bin/tag and now it works !!!
      Many thanks, now I have an easy and quick way to build a umenu without having to actually organize the files in folder.
      I just tag the files, wherever they are and send "tag --find xxxxxxx" and bam, directly into the umenu with "append".
      I get the full path in the menu but it's ok.
      Thanks again !
    • Apr 08 2016 | 8:39 am
      1. how to execute a
      Execute in the Terminal sh /Users/XYZ/Desktop/ works fine, but not with max shell.
      2. I will close a Terminal window:
      also in message box I'm struggling with::
      echo -n -e "\033]0;My Window Name\007"
      osascript -e 'tell application "Terminal" to close (every window whose name contains "My Window Name")' &
      it gives:
      echo -n -e "033]0;My Window Name007"
      so missing the \
      The result is "My Window Name)'" & instead of "My Window Name")' &
    • Apr 08 2016 | 8:50 pm
      two ways to try:
      1. append to your message the obj conformpath win nothing
      2. write your script with \ in a sprintf obj and send it with a bang
    • Apr 09 2016 | 11:12 am
      @keepsound thanks for help. I tried it out but unfortunately it does't work.
      1. if I type open instead of sh to the max shell, it opens the in an editor like xcode. So the path works well. It seems that the max shell does not work with sh or bash command.
      2. the sprintf takes out the " in the command. osascript -e ‘tell application "Terminal" to close (every window whose name contains "My Window Name")’
    • Apr 09 2016 | 1:11 pm
      I find a solution to open a with sh shell-command in max shell object.
      To close the Terminal window It works also if I know the name of the window. See the patch
    • Apr 09 2016 | 1:51 pm
      michel8 : did you try turning your script into an executable, i think the command is chmod +x
    • Apr 09 2016 | 8:11 pm
      There's a lot of formatting problems with the shell scripts, and they are different if you write osascripts. The problems are backslashes and double quotes (") that are to replaced with single quotes ('). Some are to be escaped, some are to be written in sprintf obj (the messages with backslashes)...Packing two list together with $1 $2 doesn't work, you have to use the obj zl join that retains the backslashes....if I find one of my last scripts, I'll put them here. It's a little nightmare, but at the end they works all.
    • Apr 11 2016 | 6:06 pm
      thanks Vichug and Keepsound.
      Yes I did with chmod +x to made it executable.
      Ok, zl join I didnt try. A nightmare example script would be great :)
    • Apr 11 2016 | 8:34 pm
      Some examples...
    • Apr 11 2016 | 8:36 pm
      To empty the trash folder...
    • Jun 10 2016 | 2:14 pm
      Hi Jeremy, I just downloaded your patch, but I'm having problems seeing the chess board (see image). Any thoughts about this? I'm using max 7.
      Thanks, Tom.
    • Jul 31 2016 | 10:05 am
      Hi Y'all.
      Simple problem here, I am using the wonderfull shell object to launch and get feedback from a python script. The script takes quite a while (fetches a lot of info from the internet and does some parsing), about 40secs. I use a lot of "print" inside the python script to get feedback on what is actually going on. If I launch my script with terminal, I get all my infos along the way. If I launch it within max, then I have nothing from the stdout until the script finishes, then I get all my info at once.
      Is there a way we can get infos "as they are printed" ? Hope my question is clear...
    • Sep 08 2016 | 11:14 pm
      Great object!!! How do i terminate a process (like ^C) when i use shell object. trying to stop some say-commands. Thanks!
    • Sep 08 2016 | 11:50 pm
      Hi, did you find a way to trigger multiple text to speech at the same time. Did the poly-idea work? I can not get it to work at the moment....
    • Apr 21 2017 | 11:09 am
      One question, I'm using shell to execute a python script. It works well, but the script make a zip file on the root. My problem is that shell is pointing to the root "/", how can I move to another folder. I just tryed "cd Users" but it keeps always on "/"