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.

Changes:
- 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 11 months by  Jeremy Bernstein. Reason: updated attachment
Attachments:
  1. shell.mxo_1.zip

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: shell.mxo_1.zip


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.



dtr
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.

<code>

– Pasted Max Patch, click to expand. –

</code>


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.

<code>

– Pasted Max Patch, click to expand. –

</code>


September 22, 2013 | 6:43 pm

(it seems to be something else entirely)



dtr
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:
<code>

– Pasted Max Patch, click to expand. –

</code>



ubu
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?

Thanks!


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.

Suggestions?


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?

  • This reply was modified 2 months by  leafcutter.

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?

Best,
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…


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