Terminal & max/msp

pol olory's icon

Hi everyone !
I have a question about how to communicate with Terminal in MacOs . The object is to launch a program made with Python in Terminal. What I'd like is to be able to do this in my patcher
I have somme commands to perform before launching my patch, as following :
1) Open Terminal
2) Send "sudo sysctl -w net.inet.udp.maxdgram=65535"
3) Send the User password of my computer to autorize the sudo command
4) Look for a file location. In my case : "cd /Users/CDI/Desktop/Sensible_cartography/TwitterWordsFrequency/other/"
5) Write the name of my file with the command : "python3 tweepy_streamer.py"
6) And finally run the code

Thank's folks if someone has an idea !!!

I've tried with the "shell" object But I'm only able to open the terminal with this little guy :

terminal patch.txt
text/plain 3.02 KB

Source Audio's icon

That file is not text, and not max patch,
but rtf document.
post max patch.
Second - why don't you write shell command and execute it,
instead of loosing time with shell formatting in max.

pol olory's icon

terminal patch.maxpat
Max Patch

pol olory's icon

Hi @source audio !
here is the correct format for the patch

pol olory's icon

That's what i'm actually doing : I'm writting directly in terminal and it works great !! but It would be a great thing if I could launch from max !!!

Source Audio's icon

is this all ?
launching terminal from max ?
If you can't launch it, which should work,
you maybe have permissions problem,
so that shell within max is not allowed to
execute.
Check Security & Privacy System Settings.

Other options to launch it is using message
;
max launchbrowser file:///Applications/Utilities/
Terminal.app

Source Audio's icon

send message to shell
echo 'pass' | sudo -S sysctl -w net.inet.udp.maxdgram=65535

replace pass with your password.
as alternative send
sudo sysctl -w net.inet.udp.maxdgram=65535
and after that penter followed by password

python script will need absolute path to executable and any script, slash based

pol olory's icon

Thanks for the tricks @SOURCE AUDIO ! It's ok now. The question was to choose the right path to the binary and launch that in Max :
First I used that command 'which ' and the name of the binary I want to reach... in my case python3.
Then copy the path and paste it in a message box as message for the [Shell] object.
The problem was that I was not wrting the right instructions to the object !