shell
Yes, 'pkill' is a message to the shell object which stops the current shell process. At the time the object was written, I didn't realize that 'pkill' was a command that someone would want to use. You might be able to use the message "(pkill -x TextEdit)", which would execute pkill in a subshell and not call the Max message 'pkill'. Otherwise I would add a new message to the object, something like 'run', which would allow you to 'run pkill -x TextEdit' and call pkill in that fashion.
what a tool! For default shell tasks this has been a really valuable object. I am running into an issue now when executing a binary that references ffmpeg. I have no problems running ffmpeg itself via shell object by passing the fullpath "/usr/local/bin/ffmpeg", but when I run the binary that references it I get "ffmpeg binary not found". I noticed that if I send "echo $PATH" to the object it returns "usr/bin:/usr/sbin:/sbin". Is this an issue with /usr/local/bin" not being in the object's path and is there a workaround?
I am on macOS 11.3.1 and I think the "cd" isn't working no matter which directory I put, it never goes to anywhere if I check it with "ls".
Also can't put npm to it.
is it normal?

Each message to 'shell' is its own terminal session. You'd need to use ; or && to combine your command lines.
Thank you Jeremy! Would you show me an example how exactly how those messages can be put correctly? many thanks!
Try 'cd /path/to/cd && npm run example'
the cd command still not working, already tried sth like
'cd /Desktop/to/cd'
but still it stays in the same root.
I am checking the folder by 'ls'.

/Desktop/to/cd isn't a valid path, why would you expect that to work? Nor did you follow my advice to use && to combine commands in a single message.
Try "cd ~/Desktop && ls".


1. I understand now what did you mean by "Each message to 'shell' is its own terminal session".
2. why sometimes should put ~ in front of the /?
3. The 'npm run example' is still not working, I expect there shall be value reading in the console window?
2. why sometimes should put ~ in front of the /?
in Unix systems "~” points to the user's home folder (so in MacOS corresponds to "/Users/username")

@LSKA, I also tried to put ; and I get 'no such object'. any idea where I type it wrong?
the question is, is it possible and how to use npm script correctly?
You have to provide full path to all items which are not part of default system installation,
when shell is involved.
@SOURCE AUDIO like this?
cd ~/BlitzortungAPI-master/to/cd && npm run example
but still its not working
I believe there's been a little misunderstanding between you and Jeremy some posts ago...
the correct syntax is "cd ~/BlitzortungAPI-master", all that "/to/cd" stuff whas Jeremy's example to show how subdirectories paths work.
Then, I think you'll also have to specify the full path of the npm command (which in my case is "/usr/local/bin/npm" it may be different in your case, depending how you installed npm)
why use cd at all ?
try this message to shell
/usr/local/bin/npm run ~/BlitzortungAPI-master/example.js or example.ts whatever...
in case npm is installed somewhere else, use THAT path.
And don't forget shell needs slash based path.
means if path is not on boot partition,
you have to use /Volumes/HDxy/etc etc

@LSKA my npm command is also here: /usr/local/bin/npm @SOURCE AUDIO i copied exactly this one: '/usr/local/bin/npm run ~/BlitzortungAPI-master/example.ts', but still not working..
sorry i am totally new to these command line world.
I found I got denied to enter /BlitzortungAPI-master folder
maybe thats why it doesnt work?

Simply typing the name of your path in the Terminal won't do anything -- you need to precede it with a command (cd, ls, rm, etc.).
At the risk of being "that guy", this discussion has long moved on from anything specifically related to the 'shell' object. I'm afraid that I cannot teach you how to use the command line interface, and if someone here is able to take that time, I'd appreciate if that tutorial could move into a different thread so that this thread can remain devoted to announcements, reports and requests related to 'shell'. You might want to read up on something like this: https://www.davidbaumgold.com/tutorials/command-line/
Thank you!
hi,
does anyone know if there's a command line for shell to get keyboard format information? current (qwerty, azerty?)
'sthx!
Ok i found a command line to get it, but i would need a bit of help to extract the right line which is KeyboardLayout Name =
The shell output of this command looks like a dict format, but not sure.
Any help is welcome!
thx,
improving. It's bit tricky, i just unjoin the last message in the list.
as i can only test my computer, if anyone can test on its side and tell me if he gets its own langage? thx!
You could use :
defaults read ~/Library/Preferences/com.apple.HIToolbox.plist AppleSelectedInputSources | grep 'KeyboardLayout Name'
That reads com.apple.HIToolbox.plist from user preferences, because that will show
last selected layout if multiple are enabled,
and also whenever user changes the layout.
Reading com.apple.HIToolbox.plist file from /Library/Preferences won't.
and using grep extract only a single line matched.
Otherwise you get this on output

instead of this

On Windows (10) any path output by shell lacks the slashes, probably as Max interprets the backwards slashes as quoting characters.
Example:
$ dir c:\\Users\\foo\\bar\\baz
will return
Directory of c:Usersfoobarbaz
…
It would be helpful if shell output forward slashes on Windows, too.
And no, the slash format of the input string provided to shell does not affect their output format.
Thanks!
I feel like this problem was addressed a long time ago, but I'll assume that you're using the latest/greatest, and that this isn't fixed. Will investigate at some point!
Yes, I'm using shell 1.0b2 as of 2019-02-19 which should be the latest greatest.
There is another issue that was reported earlier. On Win10, when sending the "date" command to shell, it outputs the current date twice, but subsequent issues of any command produce no output, ie shell stops accepting commands after processing the "date" command once.
Thanks for checking this.
@torsten: try this [removed] and let me know if it solves your problem with backslashes. If it works well for you, I can build a new official release.
I cannot reproduce the 'date' issue. When I send 'date' to shell on Win10, I get a prompt to set the date (two lines). I send the date (e.g. 26-07-21) and then send 'penter' to enter it. And then the shell object bangs and I can use it again.
Thanks, Jeremy! Paths work in this latest version.
The date command previously did not show the 2nd line "Enter…" which it now does. Entering 26-07-21 and sending 'penter' completes the command.
BTW "date /T" just displays the date. Both methods work.
Thanks for the extremely quick action.
Sure. New release is now up on Github and first post updated.
Hi everyone I've been using shell a lot over the past years and I feel a bit ashamed to ask this only now but... is it normal behavior for Max's audio to crack when shell is used in moderate to intense ways? An example I can produce is this. Once in a while I get clicks I don't get when the toggle is off. This is getting more annoying for examples where I'm generating data from external apps (Lisp in my case) which is supposed to be played back continuously. Any idea what I could do to improve this, apart from running two separate instances of Max? Thanks !

No, it's not normal, but there might be situations where it can happen if main thread processing takes a really long time. Now, I don't know how much stuff you have in your home directory (I have very little), so it's hard to know how long it's taking Max to process the lines being returned from the pipe connection to the shell process. The shell object spawns a different process for each message it processes in order to move processing out of Max, but maybe there are ways we can improve this, or improve the processing speed.
Have you tried using a different fork? macOS has two different fork methods, and I seem to remember that one of them is faster.
One final suggestion if there's really no getting around it: use shell to launch a script which takes text commands and then, instead of spawning new processes etc. while audio is running, send commands to the already running shell process and have it do the work.
Otherwise I'll need to do some profiling and further research, but this report isn't specific enough for me to know where to start (but I haven't tried reproducing from the image you provided yet).
Hi Jeremy, thank you for the fast reply !
Actually it's the same with any command really. My home folder has just 16 items.
What I don't understand is that the patch is basically empty, and shell is only control, why would it mess with the audio thread, especially with so little happening...?
I'm not sure what you mean by using a different fork? (for me forks are related to github, probably not the one... 😅)
I cannot use the final suggestion since I've been always relying on a new process for each command, I cannot interact with Lisp in "real" real-time. I generate by commands which are actually stored in temp files — and shell only calls the app (sbcl, the lisp distrib I use) with the path of those temp files. The data returned also goes through temp files — I read those files with bach.read when shell sends it's finish bang.
So technically shell processes very little. It is just that, I guess, 1 of 5 or 10 commands creates an audio crack no matter what is the command. My example is extreme on purpose, to highlight it, but it happens also with more sporadic calls :(
If there's anything else I can provide let me know, I'd be happy to help with this !
Hi folks! I am trying to run [shell] on an old PC running Windows 10 and I get this message and the object is not recognized (being in red).
Error 126 loading external shell
Any clues why this happens?
This typically means that you need to install a specific C++ Runtime Redistributable library from MS. I suspect that the latest shell for Windows was compiled using VS.NET C++ 2017, but if the 2017 Redistributable doesn't work, try 2015. The Dependency Walker software might help you zero in on the missing file, if you don't want to just install stuff haphazardly. If I have a sec, I can check this on my Windows dev machine.
Indeed! I fixed it. Thank you so much!!!!
Hello everyone,
I am looking for the equivalent for windows of the macOS shell command "system_profiler SPHardwareDataType" in order to retrieve system id.
In windows i assume it's the physical address, that you get with ipconfig/all in the command prompt.
Does anyone know the message to send to shell to get that information? thx!
answering myself : getmac
to get windows hardware info
wmic bios get serial number
wmic csproduct get uuid
check wmic for all available keys
Thx @source audio - but i m looking for something 'physical' and none of this seem to give me such things. I m not sure what gives you get uuid?
With "getmac" to shell, it gives you the physical address of ethernet hardware i think?
Also the bios message retunrs a value only if the field has been filled by manufactor, otherwise returns a blank data, which is desirable in what i look for.
you can use ifconfig or getmac, but there are many notebooks without ethernet at all.
One can also remove wlan card.
What remains left ?
Hard drive serial number ?
yes @source audio - so on windows what would be the equivalent of system serial number on mac?
because on mac, it is set up by apple, but for instance, my windows, i have installed my own w10 OS, and the bios request doesn't return anything. What's uuid exactly?
uuid should be unique mainboard identifier, but there is no guaranty
that noname vendors would include it into their boards.
Same as with bios serial.
This all depends what you are after,
If you want to make some sort of copy protection,
maybe hard disk serial number could do.wmic DISKDRIVE get SerialNumber
yes copy protection, that's exactly the purpose here
Problem with hard disk serial number is that
any drive will get reported, even all removable ones,
and the order of report is not given by kind.
Hi, a bug on Mac OSX with shell version shell-1.0b3:
with command ls on directory which contain symlink - but this symlink is broken - shell doesn't show this file, show the last file before symlink twice and jump about 10 next files.
I can't reproduce, I think I need some additional information, like macOS version, architecture, maybe the result of the same command in the Terminal, etc.
MacBookPro 2015; OS 10.14.6;
but I see know, that when I change the folder the result is not the same and when I duplicate the file all is working...
I had a wrong result here: ls -l ~/
and right result here: ls -l \"/Users/NAME/Documents/shell-test\"
After copy this file: lrwxrwxr-x 1 NAME staff 57 10 mar 2008 Recording -> /Users/NAME/Library/Assistants/Send Registration.setup
from first folder into the other the reslut was good and after copy back the result is good now!
I think it's a pb with my computer... :(
thanks!
Hello all,
I spotted a little error when sending the pbpaste command to [shell] to retrieve content from the clipboard on Mac.
When selecting a text that doesn't have a final carriage return, the final line is simply omitted and the penultimate line is output a second time instead. :(
The behavior is unlike the actual Terminal which prints the last line correctly and then just adds the next command prompt without skipping a line


See screenshots, I just copied the last post from MSNF above 😂 Just be careful not to select the whole text with the final break, just include the last "!". Can you reproduce this?
If you can image a temporary fix I'm interested...! Thanks
EDIT :
Google gave me a quick fix : echo "$(pbpaste)"
Here's how to do it in Max

I can reproduce it, but the pb is with shell and not with my text! :-)
Aha yes sorry, you happened to be at the wrong place at the wrong time. but it worked beautifully thanks ! 😅
The bug with last windows version of shell 1.0b3:
Error 126 loading external shell
The version 1.0b2 is working
@JULIEN VINCENOT great! work for me too now BUT
don't paste the carriage return..
when you copy text with empty lines inside you will obtain only the text without the empty lines
The same thing on windows with powershell (with version 1.02b of course)
Oh yes indeed I didn't notice !
Hm in my case it's acceptable for some reason, but I'd understand how keeping empty lines would be useful... I have no idea how to fix it though :(
@msnf re: Windows -- 1.0b3 is probably built with a newer version of Visual Studio. You almost certainly need a newer Visual C++ Redistributable installed on your system. See https://docs.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist for more information.
@julien thanks for the report, I'll look into it!
@JEREMY, yes but it's impossible for us... it's very difficult to make a modification into our system and for the moment impossible.
Maybe it could be possible to built a version with older version of VS - for example 2017?
@msnf : Nope, sorry, I'm not able to maintain multiple VS.NET versions on this machine. The source is open, though, maybe you can find someone to compile it for you.
@JEREMY, it's only question if it's possible to compile this version with VS2017. If yes I can do it.
Sure, you should be able to build it using VS2017, there's nothing specific to VS2019 in the code.
For those having error 126 loading shell 1.0.3 external and not wanting to install the VC_redistributable
one can just copy few missing DLLs into Max folder, or into Standalone folder.
Shell loads just fine like that.
If you want me to upload the files , just post.

@Jeremy
I just tried, the fix works now with pbpaste -> last line of the clipboard is printed as expected (no repetition of penultimate line), great !
Now there's another issue from MSNF's remark : empty lines are not printed as expected, see screenshot
I'm not sure if that's possible (or even desirable) in Max. I could use it of course but I can probably live without.



@SOURCE AUDIO if there are only one or some files to put into a folder on windows and without any other installation it's look very interesting for us!
@JULIEN VINCENOT you are right, for the moment I don't need any empty line, but who knows if you need paste a special text...
@SOURCE AUDIO doesn't' work... :(

@MSNF True, in my case I'm building a patch to help practice language speaking with audio materials (the least musical use I made of Max so far...). The "subtitles" feature I'm working on could benefit from copying line breaks as well, just for clarity and managing big texts.
P.S.
are you guys activating symout ?
print object seems to output empty line

but line feed in empty lines is not reflected in any other max object
even not in console
GREAT!!! thanks SOURCE AUDIO!!!
@ MSNF
1 you use 64 bit Max or ? so use shell.mxe64
2 did you place the DLLs into Max folder as I mentioned ?
NOT there where shell object is.
App has to see the DLLs directly, not by search path.
@SOURCE AUDIO
Wow thanks, I never heard of the symout attribute, it works fine for me now !
Also when collecting those symbols coming from shell with a bach.collect for instance, and adding extra brackets for each element (@inwrap 1) it does manage to collect empty lists as well. That's perfect behavior for me.
@SOURCE AUDIO
- Windows 10 64bit with processor 64bit, Max 8.1.8 64bit
- using shell.mxe64
- folder VC2021DLLs is into C:\Program Files\Cycling '74\Max 8 folder in the same level as Max.exe
- the same result: Error 126 loading external shell
I am afraid you don't understand what I mean with
app has to "see" the DLLs.
It can't do so if they are in subfolder.
You need to put all the DLLs directly next to Max.exe.


@SOURCE AUDIO - YES! It's working! Thank you very much, it will help us!
Changes between shell-1.0b2 and shell-1.0b3:
Hi, there is different behaviour of shell 2 and 3 with backslash - Mac/Windows same pb.
When copy this line:
f1/f2_Predely 0.0000 1040.0000 3 16276 \, f3_PdlyFbk 0 100 0 0 \, f4/f5_Delay-L 0.0000 325.0000 0 6581
with shell-1.0b2 I retrieve the same line into coll (and it's what I need!):

but with shell-1.0b3 I retrieve one backslash more in coll:

The pb is that I need obtain the same line as I copied with one backslash only (the same thing with yesterday update for Mac to copy text without CR).
Any idea how to obtain a right result?
thanks
welcome to Max backslash lottery.
I guess that doublebackslash behaviour was introduced trying to preserve windows path like
C:\\ some time ago
Backslash has special meanning in Max and one has to live with it.
You use it in your example line, probably to preserve comma
when passed to other max objects
I can give you a temporary solution, to feed the coll with exact line
but it needs symout active, because you also want empty lines, or ?
And how do you feed the coll ?
I don't think using prepend 1 which would allways replace a single line in coll.
so what do you want to do if this was in the clipboard ?
f1/f2_Predely 0.0000 1040.0000 3 16276 \, f3_PdlyFbk 0 100 0 0 \, f4/f5_Delay-L 0.0000 325.0000 0 6581
ha ha
f1/f2_Predely 0.04400 456.0000 3 123 \, f3_PdlyFbk 0 33 0 0 \, f4/f5_Delay-L 0.0000 122.0000 0 2345
hu hu
---------
How should that look like in coll ?
like this ?

I had some problems with clipboard and posting here.
So now this are updated screenshots and patch
Yes, this is complicated because of Max's handling of real backspace characters. This has been improved over the years, but there are still complications. In your case:
f1/f2_Predely 0.0000 1040.0000 3 16276 \, f3_PdlyFbk 0 100 0 0 \, f4/f5_Delay-L 0.0000 325.0000 0 6581
Could be put into coll like:
"f1/f2_Predely 0.0000 1040.0000 3 16276 ," "f3_PdlyFbk 0 100 0 0 ," "f4/f5_Delay-L 0.0000 325.0000 0 6581"
and then iterated on output and processed via fromsymbol (in theory I guess you don't even need the commas, unless you are populating a message box.
If you don't want to do that, you can preprocess \\, with the regexp object to become \, or a raw , could become \, or any of these general text processing options. But as of 1.0b3 we escape backslash characters arriving via stdout/stderr so that they survive C string processing without being treated like an escape character.
I would add that if coll output should look exactly like pasteboard ....
it would need \\\, stored

to come out again as :
f1/f2_Predely 0. 1040. 3 16276 \, f3_PdlyFbk 0 100 0 0 \, f4/f5_Delay-L 0. 325. 0 6581
@SOURCE AUDIO very very nice! I don't understand why this solution is working, but it's great for me ;-) I don't need more then one line for my project, my comment before was only observation, but your solution
[regexp \\, @substitute \\,]->[t b s]->[message]
is enough for me. Thank you very much for your help!
For the output from the coll I have the solution, no pb:
[1]->[coll]->[regexp , @substitute \\\\\\\\\\,]->[tosymbol]->[sprintf pbcopy %s]->[shell]
Like this I copy the line from text and paste into coll, and after that I can copy the line form coll and paste it into text. There is only one line into coll
@JEREMY Yes I need the first version of the line
f1/f2_Predely 0.0000 1040.0000 3 16276 \, f3_PdlyFbk 0 100 0 0 \, f4/f5_Delay-L 0.0000 325.0000 0 6581
It's too late to change all inside the app. The pb is hat I didn't find the solution with regexp during the hours... it's why I ask the help ;-)
Thank you guys very much for your help!
Working with Mac & Windows
I am glad you are happy and get things working.
Don't wont to bother you, but honestly I did not understand
what is the reason to store that line into coll and then paste it back.
Are you trying to exchange values between different applications via clipboard ?
And sure, I know things can get complicated when app has to run same way on different Platforms.
We have to exchange the configurations between the users who use the same app and for the moment the best and the easiest way is thru an e-mail. One line is one configuration. The same idea like copy/paste patches on the web page here.
Hi all, maybe you just have reported this issue regarding the shell object for windows (64bit architecture, but I guess also the 32bit…). what happens: I have the last shell object for win, and I send this message to it: start [path]… a folder (or directory if you prefer) opens his window, and it’s ok. But if you send the message again, the window close (but should not), and the message, if you want to open the folders window again, refuses to do it. Only a fresh restart of the computer resets the operation, not a Max restart or sending a ;max refresh message, or a loadbang to thispatcher…you can only restart the computer (or double click the selected folder or using cmd.exe (but I want to do it inside my Max applicatio/standalone). To overcome this issue, now I’m using the mxj shellAccess object (a java class is to be installed), with no issue. Also the OSX shell version has no issues. Best regards. Italo
start is not intended to open folders
https://ss64.com/nt/start.html
for that you can use explorer.exe $1 (path to folder)
Hi Source Audio. There’s another option to open folders, that is cd [path], but she’s not working at all. Never used explorer.exe, I’ll try. Thanks. (Ps start [path] with mxj shessAddredlss is working fine, same (start [patch] in cmd.exe])
Nothing, it doesn't work. See the pictures attached.
Why should it work when path is not correct ?
what is that tilde ~C: for in the path to explorer ?
if you want to use it as shortcut to users foder,
than definitely without C:
and because you are passing that path to shell / explorer, it must be
windows conform, so best is to run it to
conformpath win_native boot
directly to
explorer.exe $1 or prepend explorer.exe

--------
Some max objects can resolve unix style shortcuts on windows,
but that does not help when talking to native windows executables,
one has to form the path as expected.
I personally avoid using java at all, one does not know if it is installed
on remote systems or not.
I’ll try that too. But all the other options without the tilda doesn’t work. And a Java folder is just installed by default (in the resources folder) of all my standalones. mxj shellAccess works as expected. (Also with the cmd del)
The Tilda means User/Username
Tryied your example...it's the same as in my example: doesn't work, the Documents folder will be opened. Sorry.
Indeed this one works like before...
This one works...
This not. You need always the conformpath object....this is not right (The path was right also before, in brackets....)
First: look at the conformpath output and conform your sprintf to match it. Then you won't need it.
Second: I would prefer this thread to be about the shell object and not 11 (now 12) posts about one usage problem. At the point, I am pretty convinced that the shell object is working properly and executing exactly the command(s) you are giving it. In this case, I'd suggest moving this discussion to a new thread to work out the usage details.
I definitely agree to Jeremy's post about not plastering this so usefull
thread with such repeted trivial problems, even without reading the answers and solutions provided.
@KEEPSOUND - read that comment about using tilda !
Either you use ~/ or C:/Users/username/
But NOT ~C:/ understand that ?
tilda in front of C breaks the path, it makes no sense.
And as Jeremy points - it does not matter if you use conformpath,
sprintf, message or whatever else, path must be right for shell object,
Insert print to check output of sprintf.
And please delete all that bunch of screenshots
from this thread.
Hi Source Audio. First of all, what I showed should make the shell object better, all the screenshots remains here, for me. (I’ll remove them only if they are declared, from an admin) thaty are OT (but they are not). And some tweaks are not explained in the maxhelp of the shell object. That means that all the screenshots have to remain here. And for more precision, I add now two more screenshots. Best regards (and please, next time be more polite with the users).
Hi
I'm experiencing audio drop outs with every command sent to the shell object.
macOs 12.2, Max 8.2.2, shell 1.0b3
This was definitely not the case in earlier versions of the object.
Can someone confirm?
Please try @forkmode 1 and see if the problem goes away. The default fork on macOS appears to cause these sorts of problem.