shell


    Oct 25 2018 | 1:18 pm
    This first post will always contain a link to the latest version of shell.
    Shell is a cross-platform object for Max with which you can execute terminal commands. The shell object spawns a new shell process, executes the desired commands and passes stdout (and optionally stderr) back to Max. Latest version: https://github.com/jeremybernstein/shell/releases/tag/1.0b2 Release notes (1.0b2): - OSX: @forkmode now permits switching between fork (default, SSH-compatible) and vfork (better performance under some circumstances) - OSX: SSH works again (if using fork(), see above) - Windows: fixes for single-byte code pages on non-ANSI systems - Windows: Fix for incomplete (prompt) output for Unicode commands. Release notes (1.0b1): - c++11 rewrite (no functional change) - OSX: change fork() to vfork() to improve performance and minimize interruption when forking. - OSX: reset signal masks in the forked process - update Windows projects for Visual Studio 2015

    • Dec 31 2018 | 2:38 pm
      Thanks for keeping this object alive Jeremy, was just wondering why some of my old patches weren't working until I figured out that aka.shell didn't support 64-bit CPUs.
      Anyway, thought I'd point out that I came across this page via https://cycling74.com/tools/bernstein-shell/ which links to the old forum thread first. Nearly downloaded the 2017 version until I decided to skim through the whole page first and found the link to here. Might be worth updating the links :)
    • Dec 31 2018 | 4:49 pm
      thanks for the note, I've updated the link on the tool page.
    • Jan 08 2019 | 9:57 am
      Does anyone know how to close/quit a specific application or file that is currently open? Via shell (or otherwise if possible).
      I'm on windows and I'm able to open the file or application via shell by just sending the directory of it to shell, but would like to be able to close it as well. Tried pkill but that does not seem to take extra arguments.
      Any ideas?
      Thanks.
    • Jan 09 2019 | 8:11 am
      taskkill or tskill is windows equivalent of unix pkill
      To forcefully kill only this process
      taskkill /IM SomeApp.exe /F To forcefully kill this process and any child processes started by it taskkill /IM SomeApp.exe /T /F
    • Jan 10 2019 | 8:20 pm
      Thank's for this beautiful object ! On os x 10.13 ssh doesn't work (on my computer) but on my other computer 10.9 it works fine any ideas ? Thank's
    • Jan 28 2019 | 12:19 pm
      Thanks for the great and highly useful shell object. On Win 10, shell.mxe64 (as of Oct 25 2018) in Max8.0.2 cannot be used on systems set to Asian languages when commands return Asian characters, though. For example on Korean systems: $ ipconfig /all crashes Max reliably as the returned data contains Korean characters. The 20170717 shell version behaves the same, as does shell.2018 on Japanese localizations. Looking into this would be highly appreciated.
      Thanks!!
    • Feb 14 2019 | 6:21 am
      Hi all, Did anyone on Windows try to control other programming languages from the new shell object?
      I develop a pedagogical package called MOZLib, dedicated to computer aided composition and that works as an introduction to the bach & cage packages A big part of it uses SBCL (www.sbcl.org/platform-table.html) to reactualize composition techniques developed on PatchWork, OpenMusic and PWGL in the 1980s-2000s. It work beautifully on Mac, but I never had the occasion to test it on PC since Windows 10.
      If someone is interested to give me a hand with this, it would be fantastic. I'm planning for a first release around April.
      Thanks,
      Julien
    • Feb 14 2019 | 8:18 am
      Anyone on OSX who is having SSH issues, please try this version: https://expr-i0.net/shell_ssh.zip
      There is a new attribute @forkmode. For the previous release, shell was forking with 'vfork' in order to eliminate CPU spikes encountered in (for instance) Live when executing certain kinds of scripts. 'vfork' is useful for this, but disables SIGTTOU and SIGTTIN signals in the child process which are used for interactive input in ssh. You can now select either 'fork' (default, works with ssh) or 'vfork' (less overhead when forking, won't work for ssh), and because it's an attribute, you can change it on the fly depending on your needs.
      For in-box usage, @forkmode 0 = fork, @forkmode 1 = vfork.
      This is OSX-only (the attribute is invisible on Windows and has no effect). If I can get some feedback, I'll roll the changes into an updated release above.
    • Feb 15 2019 | 9:35 am
      Coming back to the difficulties using shell on Win10 with Asian character sets which should be resolved asap. Setting Win10 to e.g. Korean (and back) is just 2 steps: - in Win10 Settings/Time&Language, select Region&language, click Add a language, select Korean, in the Korean field click the Options button and DL the typing pack, click Set as default - right-click the Start menu, open Powershell in Admin mode, type "Set-WinSystemLocale ko-KR" - reboot - in command type e.g. "ipconfig /all"; you should see Asian characters in the output - open shell.maxhelp and send the same command, over here Max8 crashes - to get back to English: in Win10 Settings select English, click Set as default - open Powershell in Admin mode, type "Set-WinSystemLocale en-US" - reboot Thanks for setting this straight.
      Torsten
    • Feb 15 2019 | 9:42 am
      Torsten, it's a free, unsupported and (if you want to try figuring it out yourself) open-source external. I certainly understand your frustration, but it will be resolved when there's time to devote to setting up a system for korean and figuring out the problem. A much more common and pressing issue -- broken SSH on OSX -- took a couple of months to get around to, so thanks for your patience.
      That all said, thanks for the reproduction steps, which will help with the above. Not sure when I'll be able to look at it, though.
    • Feb 15 2019 | 9:51 am
      Sure, perfectly understood. Thanks again for the great object and your support.
    • Feb 19 2019 | 1:59 pm
      @torsten, please test https://expr-i0.net/shell_win_190219.zip and let me know how it goes. Turned out to be a pretty annoying issue involving non-Unicode, single-bytes Windows code pages (charsets). Seems to be working for me now.
    • Feb 19 2019 | 3:25 pm
      Tested shell_win_190219.mxe64 on Win10. - shell works on en-US system as before - when set to ko-KR (Korean) as described above shell processes Asian characters without the slightest hitch - tested commands: ipconfig /all, arp -a, getmac, ping /n 1 localhost
      Thanks, Jeremy!
      - of no significance, just for the record, sending the command "date" to shell prints the output twice; then shell does not react to any further commands. Same behavior on both Win10 en-US and ko-KR. And same behavior as in the previous (1.0b1) version of shell.
    • Feb 19 2019 | 3:54 pm
      @torsten, good call on 'date', there was a bug in handling incomplete (e.g. prompt) lines in Unicode output. Will be fixed in the next one, which will be posted to github momentarily.
    • Feb 28 2019 | 11:01 pm
      Long shot, but did anyone figure out how to use virtual environment with Python under shell?
    • Apr 26 2019 | 11:03 am
      I've been trying to trigger some npm code which works fine in Terminal, but I get no response in shell. Might there be some issue where I have to load dependencies or something (it works from scratch in Terminal)?
    • May 31 2019 | 7:31 pm
      how would I form a message if I need to send my user password to shell? RTFM link is fine, too.
    • Jun 01 2019 | 6:09 am
      example on OSX echo 'pass' | sudo -S mkdir ~/AAA
      That will make folder named AAA on desktop with admin pass pass is Your password | between pass and sudo is vertical slash , ascii 124
    • Jun 01 2019 | 9:43 am
      thanks, creating a directory works. would you know why this doesn't work for me: echo 'password' | sudo spctl --master-disable i also tried: sudo spctl --master-disable and then in a separate message: echo 'password'
    • Jun 01 2019 | 12:00 pm
      try : echo 'pass' | sudo -S spctl --master-disable
    • Jun 01 2019 | 12:06 pm
      didnt work
    • Jun 06 2019 | 1:49 pm
      I had no High Sierra at hand to confirm that above message to shell works, but now I tested it and it works as expected. Enabling / disabling gatekeeper works. So You must have some other problem. I used last published shell version at the top of this thread.
    • Jun 06 2019 | 2:37 pm
      ok good to know. i will find it eventually. it'll just take some time as i am a terminal dork. i will report my findings.
    • Jun 06 2019 | 2:43 pm
      Maybe You have system integrity protection (SIP) enabled ? You can test things using Terminal first, and if it works there, than it should also in shell.
    • Jun 06 2019 | 2:47 pm
      helvete-6:~ pureold$ csrutil status System Integrity Protection status: enabled.
      'spctl --master-disable' alwaysworks in the terminal but not through shell. I haven't found the right way to send my pwd and 'spctl --master-disable' in one message to the shell.
    • Jun 06 2019 | 3:07 pm
      if password is AAA123
      echo 'AAA123' | sudo -S spctl --master-disable
      This works for me
    • Jun 06 2019 | 3:37 pm
      this is precisely what doesn't work for me. that's my problem
    • Jun 06 2019 | 4:01 pm
      I can't explain it, I do have SIP disabled though, but I don't think that turning gatekeeper off requires SIP to be disabled.
    • Jun 07 2019 | 6:39 am
      This is working for me, and is no different than what you're trying to do.
      $ csrutil status
      System Integrity Protection status: enabled.
    • Jun 07 2019 | 7:59 am
      What has to be mentioned is that if one sends sudo message to shell without providing the password, shell will wait forever for the password input, and will not execute any commands. One has to close and reopen patch, sometimes even restart max to get it going again. To confirm that password is set correctly send this to shell: echo 'pass' | sudo -S whoami ( put correct password in) should output root message whoami should output user name ---------- Is the password the problem ? Try temporary changing the password to something simple, like a single letter, just to make sure, and avoid spaces. And don't use terminal and max with shell at same time. sudo -K command can be used in terminal to clear password cache which gets stored after initial entry for a limited time. Don't know what else to suggest to troubleshoot the problem
    • Aug 09 2019 | 2:52 pm
      Hi Jeremy! Great work with this shell object! Really saved my day :) I would simply suggest an update: adding alias. I was trying to run this in order to test something like firmware updates directly from a Max patch. Using the alias method on the shell was simply not reacting (no errors, but also not uploading the arduino file). I was able to do it replacing the alias with the file path. Although this is fine for me, I can imagine some people running into troubles if they have huge file paths for their implementations. Anyway...great job! Thank you
    • Aug 09 2019 | 8:21 pm
      Hi, every time you send a command to 'shell', it's creating a new login shell, so you don't have persistence (or crosstalk, if you like) between invocations. You can probably add that alias to your .bashrc such that it works every time you use 'shell', although I haven't tested it. Glad the object is working for you!
    • Sep 08 2019 | 1:51 pm
      Hello, I'm trying to launch some Processing patches via the shell object using the command line installation of Processing. However, the shell object shows no reaction to the command "processing-java" or to full commands like "processing-java --sketch=<filepath> --run". It also didn't print anything in reaction to "processing-java --help". All other commands have been working fine ("echo", "pwd", etc. all printed expected results). The workaround that I thought of was to store the processing launch command in a .sh file, and launch the .sh via the shell object, but I can't seem to get any .sh files to launch either. Any recommendations on what to look into? Is this even possible via the shell object? This object has otherwise served me very well in the past! Thanks
      EDIT-September 9: Okay, I think the main issue was message formatting in Max. I've gotten shell to successfully launch shell scripts by opening them in Terminal. (open -a Terminal \"<path-to-.sh-file>\") passed as a message into shell opens a terminal window and runs the script. Not a perfect solution but it works. Another possibility is to export all of the Processing sketches as applications, and launch them using the "open" command in a similar way.